5
5
6
6
module RSpec
7
7
module Rails
8
+ def self . disable_testunit_autorun
9
+ # `Test::Unit::AutoRunner.need_auto_run=` was introduced to the test-unit
10
+ # gem in version 2.4.9. Previous to this version `Test::Unit.run=` was
11
+ # used. The implementation of test-unit included with Ruby has neither
12
+ # method.
13
+ if defined? ( Test ::Unit ::AutoRunner . need_auto_run = ( ) )
14
+ Test ::Unit ::AutoRunner . need_auto_run = false
15
+ elsif defined? ( Test ::Unit . run = ( ) )
16
+ Test ::Unit . run = false
17
+ end
18
+ end
19
+ private_class_method :disable_testunit_autorun
20
+
8
21
if ::Rails ::VERSION ::STRING >= '4.1.0'
9
22
if defined? ( Kernel . gem )
10
23
gem 'minitest'
@@ -37,7 +50,7 @@ module Rails
37
50
# date). If so, we turn the auto runner off.
38
51
require 'test/unit'
39
52
require 'test/unit/assertions'
40
- Test :: Unit :: AutoRunner . need_auto_run = false if defined? ( Test :: Unit :: AutoRunner . need_auto_run = ( ) )
53
+ disable_testunit_autorun
41
54
rescue LoadError => e
42
55
raise LoadError , <<-ERR . squish , e . backtrace
43
56
Ruby 2.2+ has removed test/unit from the core library. Rails
@@ -62,7 +75,7 @@ module Rails
62
75
require 'test/unit/assertions'
63
76
end
64
77
# Turn off test unit's auto runner for those using the gem
65
- Test :: Unit :: AutoRunner . need_auto_run = false if defined? ( Test :: Unit :: AutoRunner . need_auto_run = ( ) )
78
+ disable_testunit_autorun
66
79
# Constant aliased to either Minitest or TestUnit, depending on what is
67
80
# loaded.
68
81
Assertions = Test ::Unit ::Assertions
0 commit comments