aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/test_unit
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-06-25 19:08:26 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2017-07-10 20:40:16 +0200
commit0d72489b2a08487f71dd4230846c01a5d99ef35f (patch)
tree361e00c0c82de24f359bbe5ba32b76d9913c609e /railties/test/test_unit
parentb6300f3ecc79bff29cf9bb804a30fd92403feac1 (diff)
downloadrails-0d72489b2a08487f71dd4230846c01a5d99ef35f.tar.gz
rails-0d72489b2a08487f71dd4230846c01a5d99ef35f.tar.bz2
rails-0d72489b2a08487f71dd4230846c01a5d99ef35f.zip
* Don't eagerly require Rails' minitest plugin.
By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
Diffstat (limited to 'railties/test/test_unit')
-rw-r--r--railties/test/test_unit/reporter_test.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/railties/test/test_unit/reporter_test.rb b/railties/test/test_unit/reporter_test.rb
index 98201394cd..42f973357b 100644
--- a/railties/test/test_unit/reporter_test.rb
+++ b/railties/test/test_unit/reporter_test.rb
@@ -70,7 +70,7 @@ class TestUnitReporterTest < ActiveSupport::TestCase
@reporter.record(errored_test)
@reporter.report
- expect = %r{\AE\n\nError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n No backtrace\n\nbin/rails test .*test/test_unit/reporter_test\.rb:\d+\n\n\z}
+ expect = %r{\AE\n\nError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n \n\nbin/rails test .*test/test_unit/reporter_test\.rb:\d+\n\n\z}
assert_match expect, @output.string
end
@@ -150,7 +150,7 @@ class TestUnitReporterTest < ActiveSupport::TestCase
colored = Rails::TestUnitReporter.new @output, color: true, output_inline: true
colored.record(errored_test)
- expected = %r{\e\[31mE\e\[0m\n\n\e\[31mError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n No backtrace\n\e\[0m}
+ expected = %r{\e\[31mE\e\[0m\n\n\e\[31mError:\nTestUnitReporterTest::ExampleTest#woot:\nArgumentError: wups\n \n\e\[0m}
assert_match expected, @output.string
end
end
@@ -171,8 +171,11 @@ class TestUnitReporterTest < ActiveSupport::TestCase
end
def errored_test
+ error = ArgumentError.new("wups")
+ error.set_backtrace([ "some_test.rb:4" ])
+
et = ExampleTest.new(:woot)
- et.failures << Minitest::UnexpectedError.new(ArgumentError.new("wups"))
+ et.failures << Minitest::UnexpectedError.new(error)
et
end