From 7cdf692ecbc641a9226f45e713b6eb45b3f53f0e Mon Sep 17 00:00:00 2001 From: ankit shah Date: Fri, 21 Sep 2018 15:31:19 -0700 Subject: [PATCH 1/2] load .env.test when running with bundle exec rails test file.rb instead of using .env --- config/boot.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/boot.rb b/config/boot.rb index 846949810a..f4ebce9769 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true require 'bundler/setup' + raise "ENV clearing failed" if File.expand_path(ENV.fetch("BUNDLE_GEMFILE")) != File.expand_path("Gemfile") + +ENV["RAILS_ENV"] = "test" if ARGV[0] == "test" # configure test env early when running `bundle exec rails test some_test.rb` require_relative 'dotenv' + rails_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' if ['development', 'test'].include?(rails_env) require 'bootsnap' From e98b74be988baf9031ae5e9a83347d01ef0c5fbe Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Fri, 21 Sep 2018 16:57:31 -0700 Subject: [PATCH 2/2] fix rubocop --- config/boot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/boot.rb b/config/boot.rb index f4ebce9769..4ae8825e6b 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -3,7 +3,7 @@ raise "ENV clearing failed" if File.expand_path(ENV.fetch("BUNDLE_GEMFILE")) != File.expand_path("Gemfile") -ENV["RAILS_ENV"] = "test" if ARGV[0] == "test" # configure test env early when running `bundle exec rails test some_test.rb` +ENV["RAILS_ENV"] = "test" if ARGV[0] == "test" # configure test env early for `bundle exec rails test some_test.rb` require_relative 'dotenv' rails_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'