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
before do
Readline::HISTORY.clear
Readline::HISTORY.shift until Readline::HISTORY.empty?
@hist = Readline::HISTORY
end
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 "world"
str_output = StringIO.new
@ -23,6 +24,7 @@ describe "Pry::Commands" do
end
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"
str_output = StringIO.new
redirect_pry_io(InputTester.new("hist --replay 0", "self", "exit-all"), str_output) do
@ -32,6 +34,7 @@ describe "Pry::Commands" do
end
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 ":carl"
str_output = StringIO.new
@ -92,44 +95,46 @@ describe "Pry::Commands" do
$str_output = nil
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)
if RUBY_VERSION =~ /1.9/
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
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
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)
str_output.string.should =~ /def dyna_method/
Object.remove_method :dyna_method
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
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)
str_output.string.should =~ /def yo/
Object.remove_const :A
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
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)
str_output.string.should =~ /define_method\(:yup\)/
Object.remove_const :A
end
str_output.string.should =~ /define_method\(:yup\)/
Object.remove_const :A
end
end