diff options
author | James Wen <jrw2175@columbia.edu> | 2016-02-01 00:13:05 -0500 |
---|---|---|
committer | James Wen <jrw2175@columbia.edu> | 2016-02-01 08:39:42 -0500 |
commit | d9ac903e5308739e28a66957041143da47493258 (patch) | |
tree | a3316f6ea48943fff2117db72fe65a67005021e2 | |
parent | c71bdfc892214babefc4c993bba0e23546fe7367 (diff) | |
download | bundler-d9ac903e5308739e28a66957041143da47493258.tar.gz |
Add unit tests for `Bundler::PathPreserver` module
-rw-r--r-- | spec/bundler/path_preserver_spec.rb | 54 |
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 |