summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2022-03-05 18:57:16 -0300
committerAndré Luis Leal Cardoso Junior <andrehjr@gmail.com>2022-03-05 21:48:23 -0300
commit01c0e02002b07835ea30dd3e161b8032b619b961 (patch)
tree8871cbfd7f7be046786fff3db0ab2fff63d4a885 /spec
parent6292a91a0b628a1eb0bb2f78ffc588651804d7d5 (diff)
downloadpry-01c0e02002b07835ea30dd3e161b8032b619b961.tar.gz
Build expected_path properly for other platforms
Diffstat (limited to 'spec')
-rw-r--r--spec/history_spec.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/spec/history_spec.rb b/spec/history_spec.rb
index 5cf63f72..71f8af55 100644
--- a/spec/history_spec.rb
+++ b/spec/history_spec.rb
@@ -49,14 +49,16 @@ RSpec.describe Pry::History do
end
context "when $XDG_DATA_HOME is defined" do
+ let(:expected_file_path) { File.expand_path('/my/path/pry/pry_history') }
+
it "returns config location relative to $XDG_DATA_HOME" do
stub_hist has_default: false, xdg_home: '/my/path'
- expect(described_class.default_file).to eq('/my/path/pry/pry_history')
+ expect(described_class.default_file).to eq(expected_file_path)
end
it "returns config location relative to $XDG_DATA_HOME when ~/.pryrc exists" do
stub_hist has_default: true, xdg_home: '/my/path'
- expect(described_class.default_file).to eq('/my/path/pry/pry_history')
+ expect(described_class.default_file).to eq(expected_file_path)
end
end
end
@@ -189,8 +191,9 @@ RSpec.describe Pry::History do
history = Pry::History.new(file_path: '~/test_history')
error = Class.new(RuntimeError)
+ expected_path = File.expand_path(File.join(ENV['HOME'].to_s, "/test_history"))
expect(File).to receive(:open)
- .with(File.join(ENV['HOME'].to_s, "/test_history"), 'a', 0o600)
+ .with(expected_path, 'a', 0o600)
.and_raise(error)
expect { history.push 'a line' }.to raise_error error