1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

move ENV["BACKTRACE"] support into the TestRunner.

This commit is contained in:
Yves Senn 2015-01-30 16:19:37 +01:00
parent ac5ead59ae
commit 6ccbeb458a
3 changed files with 12 additions and 3 deletions

View file

@ -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'

View file

@ -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]"

View file

@ -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]