From a42a41f7539f06390ac657444dc39656cbd5debc Mon Sep 17 00:00:00 2001 From: Noah Silvera Date: Mon, 22 Feb 2021 13:09:48 -0800 Subject: Don't set global environment variables in tests If you set the `ENV` variable in a test, this carries over to other tests. This was affecting different tests which relied on the environment. Co-authored-by: Nick Van Doorn --- spec/super_good/solidus_taxjar/api_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index df46a11..cdfed4e 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -5,7 +5,8 @@ RSpec.describe SuperGood::SolidusTaxjar::Api do subject { described_class.new } before do - ENV["TAXJAR_API_KEY"] = 'taxjar_api_token' + allow(ENV).to receive(:fetch).and_call_original + allow(ENV).to receive(:fetch).with("TAXJAR_API_KEY").and_return("taxjar_api_token") end it "sets the correct headers" do @@ -21,7 +22,8 @@ RSpec.describe SuperGood::SolidusTaxjar::Api do subject { described_class.default_taxjar_client } before do - ENV["TAXJAR_API_KEY"] = 'taxjar_api_token' + allow(ENV).to receive(:fetch).and_call_original + allow(ENV).to receive(:fetch).with("TAXJAR_API_KEY").and_return("taxjar_api_token") end it "returns an instance of the TaxJar client" do -- cgit v1.2.3