Skip to content

Commit

Permalink
added more tests for show-doc and play
Browse files Browse the repository at this point in the history
  • Loading branch information
banister committed Jan 23, 2012
1 parent 7671aa6 commit 63ac93a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test_default_commands/test_documentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
str_output.string.should =~ /sample doc/
end


it 'should output a method\'s documentation with line numbers (base one)' do
redirect_pry_io(InputTester.new("show-doc sample_method -b", "exit-all"), str_output=StringIO.new) do
pry
end

str_output.string.should =~ /1: sample doc/
end

it 'should output a method\'s documentation with line numbers (base one)' do
redirect_pry_io(InputTester.new("show-doc sample_method -l", "exit-all"), str_output=StringIO.new) do
pry
end

str_output.string.should =~ /\d: sample doc/
end

it 'should output a method\'s documentation if inside method without needing to use method name' do
o = Object.new

Expand Down
39 changes: 39 additions & 0 deletions test/test_default_commands/test_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,45 @@
str_output.string.should.not =~ /goodbye/
end

it 'should play documentation with the -d switch' do
o = Object.new

# @v = 10
# @y = 20
def o.test_method
:test_method_content
end

redirect_pry_io(InputTester.new('play -d test_method', "exit-all"), str_output = StringIO.new) do
o.pry
end

o.instance_variable_get(:@v).should == 10
o.instance_variable_get(:@y).should == 20
end

it 'should play documentation with the -d switch (restricted by --lines)' do
o = Object.new

# @x = 0
# @v = 10
# @y = 20
# @z = 30
def o.test_method
:test_method_content
end

redirect_pry_io(InputTester.new('play -d test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
o.pry
end

o.instance_variable_get(:@x).should == nil
o.instance_variable_get(:@z).should == nil
o.instance_variable_get(:@v).should == 10
o.instance_variable_get(:@y).should == 20
end


it 'should play a method with the -m switch (a single line)' do
o = Object.new
def o.test_method
Expand Down

0 comments on commit 63ac93a

Please sign in to comment.