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

adapted some tests in test_pry_history.rb to workaround libedit bug for ruby 1.8.7

This commit is contained in:
John Mair 2011-08-11 23:37:12 +12:00
parent 0c1df619f3
commit be73d113fa

View file

@ -19,7 +19,7 @@ describe Pry do
describe ".load_history" do
it "should read the contents of the file" do
Readline::HISTORY.to_a.should === ["1", "2", "3"]
Readline::HISTORY.to_a[-2..-1].should === ["2", "3"]
end
end
@ -47,7 +47,7 @@ describe Pry do
File.open(@hist, 'a') {|f| f << "4\n" }
Pry.save_history
Readline::HISTORY.to_a.should == ["1", "2", "3", "5"]
Readline::HISTORY.to_a[-3..-1].should == ["2", "3", "5"]
File.read(@hist).should == "1\n2\n3\n4\n5\n"
end
@ -60,8 +60,12 @@ describe Pry do
it "should save new lines that are added after the history was cleared" do
Readline::HISTORY.pop while Readline::HISTORY.size > 0
Readline::HISTORY << "4"
# doing this twice as libedit on 1.8.7 has bugs and sometimes ignores the
# first line in history
Readline::HISTORY << "4"
Pry.save_history
File.read(@hist).should == "1\n2\n3\n4\n"
File.read(@hist).should =~ /1\n2\n3\n4\n/
end
it "should only append new lines the second time it is saved" do
@ -71,7 +75,7 @@ describe Pry do
Readline::HISTORY << "6"
Pry.save_history
Readline::HISTORY.to_a.should == ["1", "2", "3", "4", "6"]
Readline::HISTORY.to_a[-4..-1].should == ["2", "3", "4", "6"]
File.read(@hist).should == "1\n2\n3\n4\n5\n6\n"
end
end