From 1a47bd37a1bc4b33980ba0c97bae9ba54b8d2cfb Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 23 Jun 2017 21:01:32 -0700 Subject: Reset the state of StubENV's @env_already_stubbed after each spec run In certain combination of tests, @env_already_stubbed could be set to `true` even though it never ran for that specific test. --- spec/support/stub_env.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/support/stub_env.rb b/spec/support/stub_env.rb index 18597b5c71f..2999bcd9fb1 100644 --- a/spec/support/stub_env.rb +++ b/spec/support/stub_env.rb @@ -5,3 +5,11 @@ module StubENV allow(ENV).to receive(:[]).with(key).and_return(value) end end + +# It's possible that the state of the class variables are not reset across +# test runs. +RSpec.configure do |config| + config.after(:each) do + @env_already_stubbed = nil + end +end -- cgit v1.2.1