Skip to content

Commit

Permalink
Allow loading pryrc in other location even if XDG env is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ttych committed Apr 16, 2021
1 parent 0aae8c9 commit 3c36797
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions spec/config_spec.rb
Expand Up @@ -80,25 +80,61 @@
allow(File).to receive(:exist?)
end

context "and when ~/.pryrc exists" do
context "and when $XDG_CONFIG_HOME/pry/pryrc exists" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(true)
allow(File).to receive(:exist?).and_return(true)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
context "and when ~/.pryrc exists" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(true)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
end
end

context "and when ~/.pryrc doesn't exist" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(false)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
end
end
end

context "and when ~/.pryrc doesn't exist" do
context "and when $XDG_CONFIG_HOME/pry/pryrc doesn't exist" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(false)
.with(File.expand_path('/xdg_home/pry/pryrc'))
.and_return(false)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
context "and when ~/.pryrc exists" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(true)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
end
end

context "and when ~/.pryrc doesn't exist" do
before do
allow(File).to receive(:exist?)
.with(File.expand_path('~/.pryrc')).and_return(false)
end

it "defaults to $XDG_CONFIG_HOME/pry/pryrc" do
expect(subject.rc_file).to eq('/xdg_home/pry/pryrc')
end
end
end
end
Expand Down

0 comments on commit 3c36797

Please sign in to comment.