summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorA. Nackov <anackov@gmail.com>2019-06-04 18:36:51 +0300
committerA. Nackov <anackov@gmail.com>2019-06-05 18:29:45 +0300
commit19c51bcbd15895e8fa4eb6b3c1cbe0c726c5801c (patch)
tree0d8682f966e65db7432a83714542b63767c2e788 /spec
parent6cc6e55f205c421ca6ca010a8afcafc3ed7dc299 (diff)
downloadpry-19c51bcbd15895e8fa4eb6b3c1cbe0c726c5801c.tar.gz
Close #2054 - prefer XDG_* paths (if set)
References #2054 Using XDG_* paths (if set) with preference higher than the home dir, for pry config and history files. Testing: ran `bundle exec rspec`, observed the tests pass.
Diffstat (limited to 'spec')
-rw-r--r--spec/config_spec.rb29
-rw-r--r--spec/history_spec.rb5
2 files changed, 26 insertions, 8 deletions
diff --git a/spec/config_spec.rb b/spec/config_spec.rb
index d42d4d1e..d2cda05e 100644
--- a/spec/config_spec.rb
+++ b/spec/config_spec.rb
@@ -67,18 +67,31 @@ RSpec.describe Pry::Config do
end
context "when $XDG_CONFIG_HOME is defined" do
- before do
- allow(File).to receive(:exist?)
- expect(File).to receive(:exist?)
- .with(File.expand_path('~/.pryrc')).and_return(false)
+ before { ENV['XDG_CONFIG_HOME'] = '/xdg_home' }
+ after { ENV.delete('XDG_CONFIG_HOME') }
+
+ context "when ~/.pryrc exists" do
+ before do
+ allow(File).to receive(:exist?)
+ expect(File).to receive(:exist?)
+ .with(File.expand_path('~/.pryrc')).and_return(true)
+ end
- ENV['XDG_CONFIG_HOME'] = '/xdg_home'
+ it "defaults $XDG_CONFIG_HOME/pry/pryrc" do
+ expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
+ end
end
- after { ENV.delete('XDG_CONFIG_HOME') }
+ context "when ~/.pryrc doesn't exist" do
+ before do
+ allow(File).to receive(:exist?)
+ expect(File).to receive(:exist?)
+ .with(File.expand_path('~/.pryrc')).and_return(false)
+ end
- it "defaults $XDG_CONFIG_HOME/pry/pryrc" do
- expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
+ it "defaults $XDG_CONFIG_HOME/pry/pryrc" do
+ expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
+ end
end
end
end
diff --git a/spec/history_spec.rb b/spec/history_spec.rb
index bc3de4dd..5cf63f72 100644
--- a/spec/history_spec.rb
+++ b/spec/history_spec.rb
@@ -53,6 +53,11 @@ RSpec.describe Pry::History do
stub_hist has_default: false, xdg_home: '/my/path'
expect(described_class.default_file).to eq('/my/path/pry/pry_history')
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')
+ end
end
end