aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/rails/test_unit/minitest_plugin.rb3
-rw-r--r--railties/lib/rails/test_unit/runner.rb2
-rw-r--r--railties/test/test_unit/runner_test.rb10
3 files changed, 12 insertions, 3 deletions
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb
index 149aad372c..70ce9d3360 100644
--- a/railties/lib/rails/test_unit/minitest_plugin.rb
+++ b/railties/lib/rails/test_unit/minitest_plugin.rb
@@ -7,9 +7,8 @@ def Minitest.plugin_rails_init(options)
options[:filter] = method
end
- if ENV["BACKTRACE"].nil? && !($rails_test_runner && $rails_test_runner.show_backtrace?)
+ if !($rails_test_runner && $rails_test_runner.show_backtrace?)
Minitest.backtrace_filter = Rails.backtrace_cleaner
end
end
Minitest.extensions << 'rails'
-
diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb
index 5a1b98d534..aec4707947 100644
--- a/railties/lib/rails/test_unit/runner.rb
+++ b/railties/lib/rails/test_unit/runner.rb
@@ -7,7 +7,7 @@ module Rails
class TestRunner
class Options
def self.parse(args)
- options = { backtrace: false, name: nil, environment: "test" }
+ options = { backtrace: !ENV["BACKTRACE"].nil?, name: nil, environment: "test" }
opt_parser = ::OptionParser.new do |opts|
opts.banner = "Usage: bin/rails test [options] [file or directory]"
diff --git a/railties/test/test_unit/runner_test.rb b/railties/test/test_unit/runner_test.rb
index fa5442c15c..c040c71635 100644
--- a/railties/test/test_unit/runner_test.rb
+++ b/railties/test/test_unit/runner_test.rb
@@ -1,7 +1,10 @@
require 'abstract_unit'
+require 'env_helpers'
require 'rails/test_unit/runner'
class TestUnitTestRunnerTest < ActiveSupport::TestCase
+ include EnvHelpers
+
setup do
@options = Rails::TestRunner::Options
end
@@ -19,6 +22,13 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
assert options[:backtrace]
end
+ test "show full backtrace using BACKTRACE environment variable" do
+ switch_env "BACKTRACE", "true" do
+ options = @options.parse([])
+ assert options[:backtrace]
+ end
+ end
+
test "tests run in the test environment by default" do
options = @options.parse([])
assert_equal "test", options[:environment]