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

added tests for show-method acting on dynamic pry methods

This commit is contained in:
John Mair 2011-05-25 02:57:18 +12:00
parent 6ce8da2b06
commit fc31a44fda
2 changed files with 40 additions and 0 deletions

View file

@ -51,6 +51,7 @@ end
class Module class Module
public :remove_const public :remove_const
public :remove_method
end end
class << Pry class << Pry

View file

@ -92,6 +92,45 @@ describe "Pry::Commands" do
$str_output = nil $str_output = nil
end end
it 'should output a method\'s source for a method defined inside pry' do
str_output = StringIO.new
redirect_pry_io(InputTester.new("def dyna_method", ":testing", "end", "show-method dyna_method"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end
str_output.string.should =~ /def dyna_method/
Object.remove_method :dyna_method
end
it 'should output a method\'s source for a method defined inside pry, even if exceptions raised before hand' do
str_output = StringIO.new
redirect_pry_io(InputTester.new("bad code", "123", "bad code 2", "1 + 2", "def dyna_method", ":testing", "end", "show-method dyna_method"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end
str_output.string.should =~ /def dyna_method/
Object.remove_method :dyna_method
end
it 'should output an instance method\'s source for a method defined inside pry' do
str_output = StringIO.new
redirect_pry_io(InputTester.new("class A", "def yo", "end", "end", "show-method A#yo"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end
str_output.string.should =~ /def yo/
Object.remove_const :A
end
it 'should output an instance method\'s source for a method defined inside pry using define_method' do
str_output = StringIO.new
redirect_pry_io(InputTester.new("class A", "define_method(:yup) {}", "end", "end", "show-method A#yup"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end
str_output.string.should =~ /define_method\(:yup\)/
Object.remove_const :A
end
end end
describe "show-doc" do describe "show-doc" do