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-03 15:46:41 -0700
commitcc94f6633b24633952e36956cc3fe6267b2373ef (patch)
tree64d23769aeb6537c4b1918718b0700c9c3a4ecdd
parent89f0c7839da2382439be68c7d1cbe96f75b64584 (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