summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-02-02 06:43:23 +0900
committerHomu <homu@barosl.com>2016-02-02 06:43:23 +0900
commit789dabcb48adf58175a75751c4aaf08e4c39e707 (patch)
treecced5c2bc4005d14aa36541caea9107a04743119
parentf9a3a5148e7902ae4e30e837060806067e9025f5 (diff)
parentd9ac903e5308739e28a66957041143da47493258 (diff)
downloadbundler-789dabcb48adf58175a75751c4aaf08e4c39e707.tar.gz
Auto merge of #4263 - RochesterinNYC:add-unit-test-path-preserver, r=segiddins
Add unit tests for `Bundler::PathPreserver` module - Related to #4256
-rw-r--r--spec/bundler/path_preserver_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/bundler/path_preserver_spec.rb b/spec/bundler/path_preserver_spec.rb
new file mode 100644
index 0000000000..78fda9aa40
--- /dev/null
+++ b/spec/bundler/path_preserver_spec.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+describe Bundler::PathPreserver do
+ describe "#preserve_path_in_environment" do
+ subject { described_class.preserve_path_in_environment(env_var, env) }
+
+ context "env_var is PATH" do
+ let(:env_var) { "PATH" }
+ let(:path) { "/path/here" }
+ let(:original_path) { "/original/path/here" }
+
+ context "when _ORIGINAL_PATH in env is nil" do
+ let(:env) { { "ORIGINAL_PATH" => nil, "PATH" => path } }
+
+ it "should set _ORIGINAL_PATH of env to value of PATH from env" do
+ expect(env["_ORIGINAL_PATH"]).to be_nil
+ subject
+ expect(env["_ORIGINAL_PATH"]).to eq("/path/here")
+ end
+ end
+
+ context "when original_path in env is empty" do
+ let(:env) { { "_ORIGINAL_PATH" => "", "PATH" => path } }
+
+ it "should set _ORIGINAL_PATH of env to value of PATH from env" do
+ expect(env["_ORIGINAL_PATH"]).to be_empty
+ subject
+ expect(env["_ORIGINAL_PATH"]).to eq("/path/here")
+ end
+ end
+
+ context "when path in env is nil" do
+ let(:env) { { "_ORIGINAL_PATH" => original_path, "PATH" => nil } }
+
+ it "should set PATH of env to value of _ORIGINAL_PATH from env" do
+ expect(env["PATH"]).to be_nil
+ subject
+ expect(env["PATH"]).to eq("/original/path/here")
+ end
+ end
+
+ context "when path in env is empty" do
+ let(:env) { { "_ORIGINAL_PATH" => original_path, "PATH" => "" } }
+
+ it "should set PATH of env to value of _ORIGINAL_PATH from env" do
+ expect(env["PATH"]).to be_empty
+ subject
+ expect(env["PATH"]).to eq("/original/path/here")
+ end
+ end
+ end
+ end
+end