diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-02-28 01:12:23 -0600 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2016-03-12 00:23:23 -0800 |
commit | 9422b27c4a2d9299308451d44a1513811bf8cfc1 (patch) | |
tree | 239987331773da575c055216dacb253a0d083c86 /spec | |
parent | 9f222c976f07b805efc8c4482740961c7671f23d (diff) | |
download | bundler-9422b27c4a2d9299308451d44a1513811bf8cfc1.tar.gz |
Handle quotes in PATH
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 84d2922f37..2ad3704db0 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -103,4 +103,41 @@ describe Bundler do end end end + + describe "#which" do + let(:executable) { "executable" } + let(:path) { %w(/a /b c ../d "/e") } + let(:expected) { "executable" } + + before do + ENV["PATH"] = path.join(File::PATH_SEPARATOR) + + allow(File).to receive(:file?).and_return(false) + allow(File).to receive(:executable?).and_return(false) + if expected + expect(File).to receive(:file?).with(expected).and_return(true) + expect(File).to receive(:executable?).with(expected).and_return(true) + end + end + + subject { described_class.which(executable) } + + shared_examples_for "it returns the correct executable" do + it "returns the expected file" do + expect(subject).to eq(expected) + end + end + + it_behaves_like "it returns the correct executable" + + context "when the executable in inside a quoted path" do + let(:expected) { "/e/executable" } + it_behaves_like "it returns the correct executable" + end + + context "when the executable is not found" do + let(:expected) { nil } + it_behaves_like "it returns the correct executable" + end + end end |