summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2022-03-05 21:17:43 -0300
committerAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2022-03-05 21:49:48 -0300
commitf8138c352a16925a22881557644d155e48204b1c (patch)
tree84a74ab5a43a52c0f22cbba37835eed6c45e53d7
parent9d93264e90836e88d2b7769357e8ede70c8ce89f (diff)
downloadpry-f8138c352a16925a22881557644d155e48204b1c.tar.gz
Fix Pry::History specs on windows
Co-Authored-by: SilverPhoenix99 <silver.phoenix99@gmail.com>
-rw-r--r--spec/commands/hist_spec.rb5
-rw-r--r--spec/history_spec.rb16
2 files changed, 13 insertions, 8 deletions
diff --git a/spec/commands/hist_spec.rb b/spec/commands/hist_spec.rb
index 3563d3e9..29abc8cf 100644
--- a/spec/commands/hist_spec.rb
+++ b/spec/commands/hist_spec.rb
@@ -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
diff --git a/spec/history_spec.rb b/spec/history_spec.rb
index 71f8af55..2dc98eec 100644
--- a/spec/history_spec.rb
+++ b/spec/history_spec.rb
@@ -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