mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix Pry::History specs on windows
Co-Authored-by: SilverPhoenix99 <silver.phoenix99@gmail.com>
This commit is contained in:
parent
9d93264e90
commit
f8138c352a
2 changed files with 13 additions and 8 deletions
|
@ -2,8 +2,9 @@
|
|||
|
||||
describe "hist" do
|
||||
before do
|
||||
Pry.history.clear
|
||||
@hist = Pry.history
|
||||
# different platforms require different types of Readline.
|
||||
# so best not to rely on it for these tests:
|
||||
@hist = Pry.history = Pry::History.new
|
||||
|
||||
@str_output = StringIO.new
|
||||
@t = pry_tester history: @hist do
|
||||
|
|
|
@ -4,8 +4,12 @@ require 'tempfile'
|
|||
require 'rbconfig'
|
||||
|
||||
RSpec.describe Pry::History do
|
||||
# different platforms require different types of Readline.
|
||||
# so best not to rely on it for these tests:
|
||||
let(:history) { Pry::History.new }
|
||||
|
||||
before do
|
||||
Pry.history.clear
|
||||
Pry.history = history
|
||||
|
||||
@saved_history = "1\n2\n3\ninvalid\0 line\n"
|
||||
|
||||
|
@ -201,21 +205,21 @@ RSpec.describe Pry::History do
|
|||
end
|
||||
|
||||
describe "file io errors" do
|
||||
let(:history) { Pry::History.new(file_path: file_path) }
|
||||
let(:custom_history) { Pry::History.new(file_path: file_path) }
|
||||
let(:file_path) { Tempfile.new("pry_history_spec").path }
|
||||
|
||||
[Errno::EACCES, Errno::ENOENT].each do |error_class|
|
||||
it "handles #{error_class} failure to read from history" do
|
||||
expect(File).to receive(:foreach).and_raise(error_class)
|
||||
expect(history).to receive(:warn).with(/Unable to read history file:/)
|
||||
expect { history.load }.to_not raise_error
|
||||
expect(custom_history).to receive(:warn).with(/Unable to read history file:/)
|
||||
expect { custom_history.load }.to_not raise_error
|
||||
end
|
||||
|
||||
it "handles #{error_class} failure to write history" do
|
||||
Pry.config.history_save = true
|
||||
expect(File).to receive(:open).with(file_path, "a", 0o600).and_raise(error_class)
|
||||
expect(history).to receive(:warn).with(/Unable to write history file:/)
|
||||
expect { history.push("anything") }.to_not raise_error
|
||||
expect(custom_history).to receive(:warn).with(/Unable to write history file:/)
|
||||
expect { custom_history.push("anything") }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue