1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

added more tests for show-doc and play

This commit is contained in:
John Mair 2012-01-24 02:19:26 +13:00
parent 7671aa6684
commit 63ac93a18d
2 changed files with 56 additions and 0 deletions

View file

@ -10,6 +10,23 @@ describe "Pry::DefaultCommands::Documentation" do
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

View file

@ -170,6 +170,45 @@ describe "Pry::DefaultCommands::Input" do
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