aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-12-08 16:54:57 -0600
committerGitHub <noreply@github.com>2017-12-08 16:54:57 -0600
commitbc2e08034d4ee5e38536928ae0cb90210d27ddcf (patch)
tree897d70ebbe5d43eedb457530faf4aabd3e1d08f0 /railties/lib
parentda8e0ba03cbae33857954c0c1a228bd6dae562da (diff)
parenta50b8ea3503f5642330c1e6b94320115796b4bab (diff)
downloadrails-bc2e08034d4ee5e38536928ae0cb90210d27ddcf.tar.gz
rails-bc2e08034d4ee5e38536928ae0cb90210d27ddcf.tar.bz2
rails-bc2e08034d4ee5e38536928ae0cb90210d27ddcf.zip
Merge pull request #31355 from rails/fix-rails-env-with-ruby
Fix Rails environment when running tests with Ruby
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt1
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt3
-rw-r--r--railties/lib/rails/test_unit/runner.rb2
3 files changed, 5 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
index 6ad1f11781..52d68cc77c 100644
--- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt
@@ -1,3 +1,4 @@
+ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt
index 7fa9973931..755d19ef5d 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt
+++ b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt
@@ -1,3 +1,6 @@
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+
require_relative "<%= File.join('..', options[:dummy_path], 'config/environment') -%>"
<% unless options[:skip_active_record] -%>
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../<%= options[:dummy_path] -%>/db/migrate", __dir__)]
diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb
index 5c2f6451e2..de5744c662 100644
--- a/railties/lib/rails/test_unit/runner.rb
+++ b/railties/lib/rails/test_unit/runner.rb
@@ -13,7 +13,7 @@ module Rails
class << self
def attach_before_load_options(opts)
opts.on("--warnings", "-w", "Run with Ruby warnings enabled") {}
- opts.on("--environment", "-e", "Run tests in the ENV environment") {}
+ opts.on("-e", "--environment ENV", "Run tests in the ENV environment") {}
end
def parse_options(argv)