From 0869e0531a0482ee7c17c05695201f1c8e83d0cb Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Mon, 23 Jan 2017 13:35:38 +0100 Subject: [PATCH 01/11] don't load .env.local in rails' test environment In my opinion, the .env.local should not overwrite .env.test variables. When using .env.local for tests, the tests are not transparent and can't be executed for example on a CI server. As the documentation says, the `.env.local` is here for **local** overwrites. They should not overwrite a test specific variable. Tests should be run on every machine in every environment and shouldn't require any specification of environment variables. (My opinion) --- lib/dotenv/rails.rb | 7 +- spec/dotenv/rails_development_spec.rb | 69 +++++++++++++++++++ .../{rails_spec.rb => rails_test_spec.rb} | 12 ++-- spec/fixtures/.env.development | 2 + spec/fixtures/.env.test | 1 + 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 spec/dotenv/rails_development_spec.rb rename spec/dotenv/{rails_spec.rb => rails_test_spec.rb} (84%) create mode 100644 spec/fixtures/.env.development diff --git a/lib/dotenv/rails.rb b/lib/dotenv/rails.rb index 91322d42..ca1d761a 100644 --- a/lib/dotenv/rails.rb +++ b/lib/dotenv/rails.rb @@ -35,12 +35,13 @@ class Railtie < Rails::Railtie # This will get called during the `before_configuration` callback, but you # can manually call `Dotenv::Railtie.load` if you needed it sooner. def load - Dotenv.load( + envs = [ root.join(".env.#{Rails.env}.local"), - root.join(".env.local"), root.join(".env.#{Rails.env}"), root.join(".env") - ) + ] + envs.insert(1, root.join(".env.local")) unless Rails.env == 'test' + Dotenv.load(*envs) end # Internal: `Rails.root` is nil in Rails 4.1 before the application is diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb new file mode 100644 index 00000000..4a7cb892 --- /dev/null +++ b/spec/dotenv/rails_development_spec.rb @@ -0,0 +1,69 @@ +require "spec_helper" +require "rails" +require "dotenv/rails" + +describe Dotenv::Railtie do + # Fake watcher for Spring + class SpecWatcher + attr_reader :items + + def initialize + @items = [] + end + + def add(*items) + @items |= items + end + end + + before do + ENV["RAILS_ENV"] = "development" + allow(Rails).to receive(:root) + .and_return Pathname.new(File.expand_path("../fixtures", __dir__)) + Rails.application = double(:application) + Spring.watcher = SpecWatcher.new + end + + after do + # Reset + Spring.watcher = nil + Rails.application = nil + ENV.delete "RAILS_ENV" + end + + context "before_configuration" do + it "calls #load" do + expect(Dotenv::Railtie.instance).to receive(:load) + ActiveSupport.run_load_hooks(:before_configuration) + end + end + + context "load" do + before { Dotenv::Railtie.load } + + it "watches .env with Spring" do + expect(Spring.watcher.items).to include(Rails.root.join(".env").to_s) + end + + it "watches other loaded files with Spring" do + path = fixture_path("plain.env") + Dotenv.load(path) + expect(Spring.watcher.items).to include(path) + end + + it "loads .env, .env.local, and .env.#{Rails.env}" do + p Rails.root + expect(Spring.watcher.items).to eql( + [ + Rails.root.join(".env.local").to_s, + Rails.root.join(".env.development").to_s, + Rails.root.join(".env").to_s + ] + ) + end + + it "loads .env.local before .env" do + expect(ENV["DOTENV"]).to eql("local") + end + end +end diff --git a/spec/dotenv/rails_spec.rb b/spec/dotenv/rails_test_spec.rb similarity index 84% rename from spec/dotenv/rails_spec.rb rename to spec/dotenv/rails_test_spec.rb index 371c135b..c17ba6ee 100644 --- a/spec/dotenv/rails_spec.rb +++ b/spec/dotenv/rails_test_spec.rb @@ -1,5 +1,4 @@ require "spec_helper" -ENV["RAILS_ENV"] = "test" require "rails" require "dotenv/rails" @@ -18,8 +17,9 @@ def add(*items) end before do + ENV["RAILS_ENV"] = "test" allow(Rails).to receive(:root) - .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) + .and_return Pathname.new(File.expand_path("../fixtures", __dir__)) Rails.application = double(:application) Spring.watcher = SpecWatcher.new end @@ -28,6 +28,7 @@ def add(*items) # Reset Spring.watcher = nil Rails.application = nil + ENV.delete "RAILS_ENV" end context "before_configuration" do @@ -50,19 +51,18 @@ def add(*items) expect(Spring.watcher.items).to include(path) end - it "loads .env, .env.local, and .env.#{Rails.env}" do + it "does not load .env.local in test rails environment" do expect(Spring.watcher.items).to eql( [ Rails.root.join(".env.test.local").to_s, - Rails.root.join(".env.local").to_s, Rails.root.join(".env.test").to_s, Rails.root.join(".env").to_s ] ) end - it "loads .env.local before .env" do - expect(ENV["DOTENV"]).to eql("local") + it "loads .env.test before .env" do + expect(ENV["DOTENV"]).to eql("test") end context "when Rails.root is nil" do diff --git a/spec/fixtures/.env.development b/spec/fixtures/.env.development new file mode 100644 index 00000000..3558c1ca --- /dev/null +++ b/spec/fixtures/.env.development @@ -0,0 +1,2 @@ +FROM_RAILS_ENV=.env.development +DOTENV=dev diff --git a/spec/fixtures/.env.test b/spec/fixtures/.env.test index 04f7cf73..4dbb7d98 100644 --- a/spec/fixtures/.env.test +++ b/spec/fixtures/.env.test @@ -1 +1,2 @@ FROM_RAILS_ENV=.env.test +DOTENV=test From c9597d62282fcf07c8b47f29c5460c6442ffd202 Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Mon, 23 Jan 2017 14:09:08 +0100 Subject: [PATCH 02/11] use __FILE__ instead of __dir__ to support legacy rubies --- spec/dotenv/rails_development_spec.rb | 2 +- spec/dotenv/rails_test_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb index 4a7cb892..e1922e44 100644 --- a/spec/dotenv/rails_development_spec.rb +++ b/spec/dotenv/rails_development_spec.rb @@ -19,7 +19,7 @@ def add(*items) before do ENV["RAILS_ENV"] = "development" allow(Rails).to receive(:root) - .and_return Pathname.new(File.expand_path("../fixtures", __dir__)) + .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) Rails.application = double(:application) Spring.watcher = SpecWatcher.new end diff --git a/spec/dotenv/rails_test_spec.rb b/spec/dotenv/rails_test_spec.rb index c17ba6ee..8e4343fd 100644 --- a/spec/dotenv/rails_test_spec.rb +++ b/spec/dotenv/rails_test_spec.rb @@ -19,7 +19,7 @@ def add(*items) before do ENV["RAILS_ENV"] = "test" allow(Rails).to receive(:root) - .and_return Pathname.new(File.expand_path("../fixtures", __dir__)) + .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) Rails.application = double(:application) Spring.watcher = SpecWatcher.new end From a1527f3b6158ab0edd348fd98b71ed77d7ae8019 Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Tue, 24 Jan 2017 09:03:59 +0100 Subject: [PATCH 03/11] fix tests --- lib/dotenv/rails.rb | 19 ++++++++++++------- spec/dotenv/rails_development_spec.rb | 10 +++++----- spec/dotenv/rails_test_spec.rb | 3 ++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/dotenv/rails.rb b/lib/dotenv/rails.rb index ca1d761a..86e796f8 100644 --- a/lib/dotenv/rails.rb +++ b/lib/dotenv/rails.rb @@ -35,13 +35,7 @@ class Railtie < Rails::Railtie # This will get called during the `before_configuration` callback, but you # can manually call `Dotenv::Railtie.load` if you needed it sooner. def load - envs = [ - root.join(".env.#{Rails.env}.local"), - root.join(".env.#{Rails.env}"), - root.join(".env") - ] - envs.insert(1, root.join(".env.local")) unless Rails.env == 'test' - Dotenv.load(*envs) + Dotenv.load(*dotenv_files) end # Internal: `Rails.root` is nil in Rails 4.1 before the application is @@ -58,5 +52,16 @@ def self.load end config.before_configuration { load } + + private + def dotenv_files + envs = [ + root.join(".env.#{Rails.env}.local"), + root.join(".env.#{Rails.env}"), + root.join(".env") + ] + envs.insert(1, root.join(".env.local")) unless Rails.env == 'test' + envs + end end end diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb index e1922e44..e476a151 100644 --- a/spec/dotenv/rails_development_spec.rb +++ b/spec/dotenv/rails_development_spec.rb @@ -20,6 +20,7 @@ def add(*items) ENV["RAILS_ENV"] = "development" allow(Rails).to receive(:root) .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) + allow(Rails).to receive(:env).and_return "development" Rails.application = double(:application) Spring.watcher = SpecWatcher.new end @@ -52,12 +53,11 @@ def add(*items) end it "loads .env, .env.local, and .env.#{Rails.env}" do - p Rails.root - expect(Spring.watcher.items).to eql( + expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( [ - Rails.root.join(".env.local").to_s, - Rails.root.join(".env.development").to_s, - Rails.root.join(".env").to_s + Rails.root.join(".env.local"), + Rails.root.join(".env.development"), + Rails.root.join(".env") ] ) end diff --git a/spec/dotenv/rails_test_spec.rb b/spec/dotenv/rails_test_spec.rb index 8e4343fd..008d45dd 100644 --- a/spec/dotenv/rails_test_spec.rb +++ b/spec/dotenv/rails_test_spec.rb @@ -20,6 +20,7 @@ def add(*items) ENV["RAILS_ENV"] = "test" allow(Rails).to receive(:root) .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) + allow(Rails).to receive(:env).and_return "test" Rails.application = double(:application) Spring.watcher = SpecWatcher.new end @@ -52,7 +53,7 @@ def add(*items) end it "does not load .env.local in test rails environment" do - expect(Spring.watcher.items).to eql( + expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( [ Rails.root.join(".env.test.local").to_s, Rails.root.join(".env.test").to_s, From d27f11d9bee89f9bf837a48ce291cc26be07d03b Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Tue, 24 Jan 2017 09:16:24 +0100 Subject: [PATCH 04/11] okay rubocop... --- lib/dotenv/rails.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dotenv/rails.rb b/lib/dotenv/rails.rb index 86e796f8..489ea561 100644 --- a/lib/dotenv/rails.rb +++ b/lib/dotenv/rails.rb @@ -54,13 +54,14 @@ def self.load config.before_configuration { load } private + def dotenv_files envs = [ root.join(".env.#{Rails.env}.local"), root.join(".env.#{Rails.env}"), root.join(".env") ] - envs.insert(1, root.join(".env.local")) unless Rails.env == 'test' + envs.insert(1, root.join(".env.local")) unless Rails.env == "test" envs end end From 0734ca167527d3f936e8cda9f4b8eaba52534cd6 Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Thu, 26 Jan 2017 09:04:17 +0100 Subject: [PATCH 05/11] rebase, adjust tests --- spec/dotenv/rails_development_spec.rb | 9 +++++---- spec/dotenv/rails_test_spec.rb | 6 +++--- .../fixtures/{.env.test.local => .env.development.local} | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) rename spec/fixtures/{.env.test.local => .env.development.local} (62%) diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb index e476a151..d63089ad 100644 --- a/spec/dotenv/rails_development_spec.rb +++ b/spec/dotenv/rails_development_spec.rb @@ -52,18 +52,19 @@ def add(*items) expect(Spring.watcher.items).to include(path) end - it "loads .env, .env.local, and .env.#{Rails.env}" do + it "loads .env, .env.#{Rails.env}, .env.local, and .env.#{Rails.env}.local" do expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( [ + Rails.root.join(".env.development.local"), Rails.root.join(".env.local"), Rails.root.join(".env.development"), - Rails.root.join(".env") + Rails.root.join(".env"), ] ) end - it "loads .env.local before .env" do - expect(ENV["DOTENV"]).to eql("local") + it "loads .env.#{Rails.env}.local on top" do + expect(ENV["DOTENV"]).to eql("development-local") end end end diff --git a/spec/dotenv/rails_test_spec.rb b/spec/dotenv/rails_test_spec.rb index 008d45dd..cd8b75eb 100644 --- a/spec/dotenv/rails_test_spec.rb +++ b/spec/dotenv/rails_test_spec.rb @@ -55,9 +55,9 @@ def add(*items) it "does not load .env.local in test rails environment" do expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( [ - Rails.root.join(".env.test.local").to_s, - Rails.root.join(".env.test").to_s, - Rails.root.join(".env").to_s + Rails.root.join(".env.test.local"), + Rails.root.join(".env.test"), + Rails.root.join(".env"), ] ) end diff --git a/spec/fixtures/.env.test.local b/spec/fixtures/.env.development.local similarity index 62% rename from spec/fixtures/.env.test.local rename to spec/fixtures/.env.development.local index 0f979e85..78996ec0 100644 --- a/spec/fixtures/.env.test.local +++ b/spec/fixtures/.env.development.local @@ -1,3 +1,3 @@ FROM_RAILS_ENV=.env.test FROM_LOCAL=true -DOTENV=local +DOTENV=development-local From b186a89b6bf38a4b15fe037d0c37feee4d316af1 Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Thu, 26 Jan 2017 09:12:37 +0100 Subject: [PATCH 06/11] [ci skip] add changelog entries for the latest pull requests --- Changelog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 4cd66a02..bf3f8484 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,8 +4,10 @@ ## 2.1.2 +* [dotenv-rails] Allow to have a local file per environment, e.g. `.env.development.local` ([281](https://github.com/bkeepers/dotenv/pull/281)) +* [dotenv-rails] No longer load `.env.local` in rails' test environment ([#280](https://github.com/bkeepers/dotenv/pull/280)) * Fix parser to allow leading whitespace before variables ([#276](https://github.com/bkeepers/dotenv/pull/276)) -* Fix bug with `require "dotenv/rails-now"` in older versions of rails ([#269](https://github.com/bkeepers/dotenv/pull/269)) +* [dotenv-rails] Fix bug with `require "dotenv/rails-now"` in older versions of rails ([#269](https://github.com/bkeepers/dotenv/pull/269)) [Full Changelog](https://github.com/bkeepers/dotenv/compare/v2.1.1...v2.1.2) From 5140a272343e6f3c798de2a038e3dd073b8aaa34 Mon Sep 17 00:00:00 2001 From: Yves Siegrist Date: Thu, 26 Jan 2017 09:16:49 +0100 Subject: [PATCH 07/11] remove trailing comma (lol rubocop) --- spec/dotenv/rails_development_spec.rb | 4 ++-- spec/dotenv/rails_test_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb index d63089ad..9ad2f672 100644 --- a/spec/dotenv/rails_development_spec.rb +++ b/spec/dotenv/rails_development_spec.rb @@ -52,13 +52,13 @@ def add(*items) expect(Spring.watcher.items).to include(path) end - it "loads .env, .env.#{Rails.env}, .env.local, and .env.#{Rails.env}.local" do + it "loads .env, .env.#{Rails.env}, .env.local, .env.#{Rails.env}.local" do expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( [ Rails.root.join(".env.development.local"), Rails.root.join(".env.local"), Rails.root.join(".env.development"), - Rails.root.join(".env"), + Rails.root.join(".env") ] ) end diff --git a/spec/dotenv/rails_test_spec.rb b/spec/dotenv/rails_test_spec.rb index cd8b75eb..d19847b3 100644 --- a/spec/dotenv/rails_test_spec.rb +++ b/spec/dotenv/rails_test_spec.rb @@ -57,7 +57,7 @@ def add(*items) [ Rails.root.join(".env.test.local"), Rails.root.join(".env.test"), - Rails.root.join(".env"), + Rails.root.join(".env") ] ) end From 49fc29eb409079d285cb4d7e7356f6f0674ead0f Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 27 Jan 2017 09:04:54 -0600 Subject: [PATCH 08/11] Update changelog --- Changelog.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index bf3f8484..944b01b5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,10 +2,15 @@ [Unreleased changes](https://github.com/bkeepers/dotenv/compare/v2.1.2...master) -## 2.1.2 +## Unreleased * [dotenv-rails] Allow to have a local file per environment, e.g. `.env.development.local` ([281](https://github.com/bkeepers/dotenv/pull/281)) * [dotenv-rails] No longer load `.env.local` in rails' test environment ([#280](https://github.com/bkeepers/dotenv/pull/280)) + +[Full Changelog](https://github.com/bkeepers/dotenv/compare/v2.1.1...v2.1.2) + +## 2.1.2 + * Fix parser to allow leading whitespace before variables ([#276](https://github.com/bkeepers/dotenv/pull/276)) * [dotenv-rails] Fix bug with `require "dotenv/rails-now"` in older versions of rails ([#269](https://github.com/bkeepers/dotenv/pull/269)) From 6cc4d4fd411044e9c178be01a30d00b35adc6dca Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 27 Jan 2017 09:05:40 -0600 Subject: [PATCH 09/11] Simplify dotenv_files --- lib/dotenv/rails.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/dotenv/rails.rb b/lib/dotenv/rails.rb index 489ea561..4ac69591 100644 --- a/lib/dotenv/rails.rb +++ b/lib/dotenv/rails.rb @@ -56,13 +56,12 @@ def self.load private def dotenv_files - envs = [ + [ root.join(".env.#{Rails.env}.local"), + (root.join(".env.local") unless Rails.env == "test"), root.join(".env.#{Rails.env}"), root.join(".env") - ] - envs.insert(1, root.join(".env.local")) unless Rails.env == "test" - envs + ].compact end end end From 40697ab4ae220b2b2d0206459f73f87bfe3ad028 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 27 Jan 2017 09:13:20 -0600 Subject: [PATCH 10/11] Consolidate rails specs --- spec/dotenv/rails_development_spec.rb | 70 ------------------- .../{rails_test_spec.rb => rails_spec.rb} | 16 ++++- 2 files changed, 13 insertions(+), 73 deletions(-) delete mode 100644 spec/dotenv/rails_development_spec.rb rename spec/dotenv/{rails_test_spec.rb => rails_spec.rb} (81%) diff --git a/spec/dotenv/rails_development_spec.rb b/spec/dotenv/rails_development_spec.rb deleted file mode 100644 index 9ad2f672..00000000 --- a/spec/dotenv/rails_development_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require "spec_helper" -require "rails" -require "dotenv/rails" - -describe Dotenv::Railtie do - # Fake watcher for Spring - class SpecWatcher - attr_reader :items - - def initialize - @items = [] - end - - def add(*items) - @items |= items - end - end - - before do - ENV["RAILS_ENV"] = "development" - allow(Rails).to receive(:root) - .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) - allow(Rails).to receive(:env).and_return "development" - Rails.application = double(:application) - Spring.watcher = SpecWatcher.new - end - - after do - # Reset - Spring.watcher = nil - Rails.application = nil - ENV.delete "RAILS_ENV" - end - - context "before_configuration" do - it "calls #load" do - expect(Dotenv::Railtie.instance).to receive(:load) - ActiveSupport.run_load_hooks(:before_configuration) - end - end - - context "load" do - before { Dotenv::Railtie.load } - - it "watches .env with Spring" do - expect(Spring.watcher.items).to include(Rails.root.join(".env").to_s) - end - - it "watches other loaded files with Spring" do - path = fixture_path("plain.env") - Dotenv.load(path) - expect(Spring.watcher.items).to include(path) - end - - it "loads .env, .env.#{Rails.env}, .env.local, .env.#{Rails.env}.local" do - expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( - [ - Rails.root.join(".env.development.local"), - Rails.root.join(".env.local"), - Rails.root.join(".env.development"), - Rails.root.join(".env") - ] - ) - end - - it "loads .env.#{Rails.env}.local on top" do - expect(ENV["DOTENV"]).to eql("development-local") - end - end -end diff --git a/spec/dotenv/rails_test_spec.rb b/spec/dotenv/rails_spec.rb similarity index 81% rename from spec/dotenv/rails_test_spec.rb rename to spec/dotenv/rails_spec.rb index d19847b3..4c511dc2 100644 --- a/spec/dotenv/rails_test_spec.rb +++ b/spec/dotenv/rails_spec.rb @@ -17,10 +17,9 @@ def add(*items) end before do - ENV["RAILS_ENV"] = "test" + Rails.env = "test" allow(Rails).to receive(:root) .and_return Pathname.new(File.expand_path("../../fixtures", __FILE__)) - allow(Rails).to receive(:env).and_return "test" Rails.application = double(:application) Spring.watcher = SpecWatcher.new end @@ -29,7 +28,6 @@ def add(*items) # Reset Spring.watcher = nil Rails.application = nil - ENV.delete "RAILS_ENV" end context "before_configuration" do @@ -62,6 +60,18 @@ def add(*items) ) end + it "does load .env.local in development environment" do + Rails.env = "development" + expect(Dotenv::Railtie.instance.send(:dotenv_files)).to eql( + [ + Rails.root.join(".env.development.local"), + Rails.root.join(".env.local"), + Rails.root.join(".env.development"), + Rails.root.join(".env") + ] + ) + end + it "loads .env.test before .env" do expect(ENV["DOTENV"]).to eql("test") end From c1ebe6cdde23ec1c7814ad8f465e8271558296e0 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 27 Jan 2017 09:14:48 -0600 Subject: [PATCH 11/11] Use inquirer method --- lib/dotenv/rails.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dotenv/rails.rb b/lib/dotenv/rails.rb index 4ac69591..92467b60 100644 --- a/lib/dotenv/rails.rb +++ b/lib/dotenv/rails.rb @@ -58,7 +58,7 @@ def self.load def dotenv_files [ root.join(".env.#{Rails.env}.local"), - (root.join(".env.local") unless Rails.env == "test"), + (root.join(".env.local") unless Rails.env.test?), root.join(".env.#{Rails.env}"), root.join(".env") ].compact