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

fixed tests for ruby 1.8 (pls remember to test against ruby 1.8 everyone! :P). Readline::HISTORY is buggy in 1.8 so had to hard-code exception -- may be fragile

This commit is contained in:
John Mair 2011-05-25 14:09:31 +12:00
parent 374b48dc31
commit 169ee11b04

View file

@ -8,11 +8,12 @@ describe "Pry::Commands" do
describe "hist" do describe "hist" do
before do before do
Readline::HISTORY.clear Readline::HISTORY.shift until Readline::HISTORY.empty?
@hist = Readline::HISTORY @hist = Readline::HISTORY
end end
it 'should display the correct history' do it 'should display the correct history' do
@hist.push "'bug in 1.8 means this line is ignored'" if RUBY_VERSION =~ /1.8/
@hist.push "hello" @hist.push "hello"
@hist.push "world" @hist.push "world"
str_output = StringIO.new str_output = StringIO.new
@ -23,6 +24,7 @@ describe "Pry::Commands" do
end end
it 'should replay history correctly (single item)' do it 'should replay history correctly (single item)' do
@hist.push "'bug in 1.8 means this line is ignored'" if RUBY_VERSION =~ /1.8/
@hist.push "cd :hello" @hist.push "cd :hello"
str_output = StringIO.new str_output = StringIO.new
redirect_pry_io(InputTester.new("hist --replay 0", "self", "exit-all"), str_output) do redirect_pry_io(InputTester.new("hist --replay 0", "self", "exit-all"), str_output) do
@ -32,6 +34,7 @@ describe "Pry::Commands" do
end end
it 'should replay a range of history correctly (range of items)' do it 'should replay a range of history correctly (range of items)' do
@hist.push "'bug in 1.8 means this line is ignored'" if RUBY_VERSION =~ /1.8/
@hist.push ":hello" @hist.push ":hello"
@hist.push ":carl" @hist.push ":carl"
str_output = StringIO.new str_output = StringIO.new
@ -92,44 +95,46 @@ 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 if RUBY_VERSION =~ /1.9/
str_output = StringIO.new it 'should output a method\'s source for a method defined inside pry' do
redirect_pry_io(InputTester.new("def dyna_method", ":testing", "end", "show-method dyna_method"), str_output) do str_output = StringIO.new
Pry.new.repl(TOPLEVEL_BINDING) 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 end
str_output.string.should =~ /def dyna_method/ it 'should output a method\'s source for a method defined inside pry, even if exceptions raised before hand' do
Object.remove_method :dyna_method str_output = StringIO.new
end 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
it 'should output a method\'s source for a method defined inside pry, even if exceptions raised before hand' do str_output.string.should =~ /def dyna_method/
str_output = StringIO.new Object.remove_method :dyna_method
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 end
str_output.string.should =~ /def dyna_method/ it 'should output an instance method\'s source for a method defined inside pry' do
Object.remove_method :dyna_method str_output = StringIO.new
end redirect_pry_io(InputTester.new("class A", "def yo", "end", "end", "show-method A#yo"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end
it 'should output an instance method\'s source for a method defined inside pry' do str_output.string.should =~ /def yo/
str_output = StringIO.new Object.remove_const :A
redirect_pry_io(InputTester.new("class A", "def yo", "end", "end", "show-method A#yo"), str_output) do
Pry.new.repl(TOPLEVEL_BINDING)
end end
str_output.string.should =~ /def yo/ it 'should output an instance method\'s source for a method defined inside pry using define_method' do
Object.remove_const :A str_output = StringIO.new
end 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
it 'should output an instance method\'s source for a method defined inside pry using define_method' do str_output.string.should =~ /define_method\(:yup\)/
str_output = StringIO.new Object.remove_const :A
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 end
str_output.string.should =~ /define_method\(:yup\)/
Object.remove_const :A
end end
end end