summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Silvera <noah@super.gd>2021-02-22 13:09:48 -0800
committerNicholas Van Doorn <vandoorn.nick@gmail.com>2021-05-12 14:53:24 -0700
commita42a41f7539f06390ac657444dc39656cbd5debc (patch)
treed6c364618f735b9df73e012b47b3e9d9b123adac
parent4c3eda59ea91458fb5af0025ecf0f6e6708f2b4f (diff)
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 <nick@super.gd>
-rw-r--r--spec/super_good/solidus_taxjar/api_spec.rb6
1 files 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