Skip to content

Commit

Permalink
Isolate env variables for the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Oct 29, 2023
1 parent 09958f3 commit f7fa802
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/shakapacker/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,14 @@
end

it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_ASSET_HOST is not set" do
original_env_value = ENV["SHAKAPACKER_ASSET_HOST"]
ENV["SHAKAPACKER_ASSET_HOST"] = nil

allow(ActionController::Base.helpers).to receive(:compute_asset_host).and_return("domain.abc")

expect(config.asset_host).to eq "domain.abc"
ensure
ENV["SHAKAPACKER_ASSET_HOST"] = original_env_value
end
end

Expand All @@ -377,9 +382,15 @@
end

it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_RELATIVE_URL_ROOT is not set" do
original_env_value = ENV["SHAKAPACKER_RELATIVE_URL_ROOT"]
ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = nil

allow(ActionController::Base).to receive(:relative_url_root).and_return("abcd")

expect(config.relative_url_root).to eq "abcd"

ensure
ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = original_env_value
end
end
end

0 comments on commit f7fa802

Please sign in to comment.