summaryrefslogtreecommitdiff
path: root/spec/bundler/bundler/environment_preserver_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/bundler/bundler/environment_preserver_spec.rb')
-rw-r--r--spec/bundler/bundler/environment_preserver_spec.rb79
1 files changed, 0 insertions, 79 deletions
diff --git a/spec/bundler/bundler/environment_preserver_spec.rb b/spec/bundler/bundler/environment_preserver_spec.rb
deleted file mode 100644
index 530ca6f835..0000000000
--- a/spec/bundler/bundler/environment_preserver_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Bundler::EnvironmentPreserver do
- let(:preserver) { described_class.new(env, ["foo"]) }
-
- describe "#backup" do
- let(:env) { { "foo" => "my-foo", "bar" => "my-bar" } }
- subject { preserver.backup }
-
- it "should create backup entries" do
- expect(subject["BUNDLER_ORIG_foo"]).to eq("my-foo")
- end
-
- it "should keep the original entry" do
- expect(subject["foo"]).to eq("my-foo")
- end
-
- it "should not create backup entries for unspecified keys" do
- expect(subject.key?("BUNDLER_ORIG_bar")).to eq(false)
- end
-
- it "should not affect the original env" do
- subject
- expect(env.keys.sort).to eq(%w[bar foo])
- end
-
- context "when a key is empty" do
- let(:env) { { "foo" => "" } }
-
- it "should not create backup entries" do
- expect(subject).not_to have_key "BUNDLER_ORIG_foo"
- end
- end
-
- context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
-
- it "should keep the original value in the BUNDLER_ORIG_ variable" do
- expect(subject["BUNDLER_ORIG_foo"]).to eq("orig-foo")
- end
-
- it "should keep the variable" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
- end
-
- describe "#restore" do
- subject { preserver.restore }
-
- context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
-
- it "should restore the original value" do
- expect(subject["foo"]).to eq("orig-foo")
- end
-
- it "should delete the backup value" do
- expect(subject.key?("BUNDLER_ORIG_foo")).to eq(false)
- end
- end
-
- context "when no original key is set" do
- let(:env) { { "foo" => "my-foo" } }
-
- it "should keep the current value" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
-
- context "when the original key is empty" do
- let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "" } }
-
- it "should keep the current value" do
- expect(subject["foo"]).to eq("my-foo")
- end
- end
- end
-end