diff --git a/spec/dotenv/rails_spec.rb b/spec/dotenv/rails_spec.rb index 1bbb6278..08c00cac 100644 --- a/spec/dotenv/rails_spec.rb +++ b/spec/dotenv/rails_spec.rb @@ -4,15 +4,17 @@ describe Dotenv::Rails do before do - # Remove the singleton instance if it exists - Dotenv::Rails.remove_instance_variable(:@instance) rescue nil - Rails.env = "test" allow(Rails).to receive(:root).and_return Pathname.new(__dir__).join("../fixtures") Rails.application = double(:application) Spring.watcher = Set.new # Responds to #add end + after do + # Remove the singleton instance if it exists + Dotenv::Rails.remove_instance_variable(:@instance) + end + after do # Reset Spring.watcher = nil @@ -53,8 +55,8 @@ context "before_configuration" do it "calls #load" do - expect(Dotenv::Rails).to receive(:load) - ActiveSupport.run_load_hooks(:before_configuration, ) + expect(Dotenv::Rails.instance).to receive(:load) + ActiveSupport.run_load_hooks(:before_configuration) end end