lib/dotenv/rails.rb in dotenv-rails-2.7.2 vs lib/dotenv/rails.rb in dotenv-rails-2.7.3
- old
+ new
@@ -7,12 +7,13 @@
# Rails includes some hacks to set `RAILS_ENV=test` when running `rake test`,
# but rspec does not include the same hacks.
#
# See https://github.com/bkeepers/dotenv/issues/219
if defined?(Rake.application)
- is_running_specs = Rake.application.top_level_tasks.grep(/^spec(:|$)/).any?
- Rails.env = ENV["RAILS_ENV"] ||= "test" if is_running_specs
+ if Rake.application.top_level_tasks.grep(/^(parallel:spec|spec(:|$))/).any?
+ Rails.env = ENV["RAILS_ENV"] ||= "test"
+ end
end
Dotenv.instrumenter = ActiveSupport::Notifications
# Watch all loaded env files with Spring
@@ -49,19 +50,19 @@
# instance, which means `Kernel#load` gets called here. We don't want that.
def self.load
instance.load
end
- config.before_configuration { load }
-
private
def dotenv_files
[
root.join(".env.#{Rails.env}.local"),
(root.join(".env.local") unless Rails.env.test?),
root.join(".env.#{Rails.env}"),
root.join(".env")
].compact
end
+
+ config.before_configuration { load }
end
end