Skip to content

Commit 2990ac5

Browse files
committed
Add ls command test
1 parent 957fd79 commit 2990ac5

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

test/irb/command/test_ls.rb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
require "tempfile"
2+
require_relative "../helper"
3+
4+
module TestIRB
5+
class LSTest < IntegrationTestCase
6+
def setup
7+
super
8+
9+
write_ruby <<~'RUBY'
10+
class Foo
11+
class Bar
12+
def bar
13+
"this is bar"
14+
end
15+
end
16+
17+
def foo
18+
"this is foo"
19+
end
20+
end
21+
22+
class BO < BasicObject
23+
ONE = 1
24+
def baz
25+
"this is baz"
26+
end
27+
end
28+
29+
binding.irb
30+
RUBY
31+
end
32+
33+
def test_ls_class
34+
out = run_ruby_file do
35+
type "ls Foo"
36+
type "exit"
37+
end
38+
39+
assert_match(/constants: Bar/, out)
40+
assert_match(/Foo#methods: foo/, out)
41+
end
42+
43+
def test_ls_instance
44+
out = run_ruby_file do
45+
type "ls Foo.new"
46+
type "exit"
47+
end
48+
49+
assert_match(/Foo#methods: foo/, out)
50+
end
51+
52+
def test_ls_basic_object
53+
out = run_ruby_file do
54+
type "ls BO"
55+
type "exit"
56+
end
57+
58+
assert_match(/constants:.*ONE/, out)
59+
assert_match(/BO#methods: baz/, out)
60+
end
61+
62+
def test_ls_basic_object_instance
63+
out = run_ruby_file do
64+
type "ls BO.new"
65+
type "exit"
66+
end
67+
68+
assert_match(/BO#methods: baz/, out)
69+
end
70+
end
71+
end

0 commit comments

Comments
 (0)