File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ def assertion_method_names
201
201
select do |m |
202
202
m . to_s =~ /^(assert|flunk|refute)/
203
203
end
204
- methods + [ :build_message ]
204
+ methods + test_unit_specific_methods
205
205
end
206
206
207
207
def define_assertion_delegators
@@ -211,6 +211,18 @@ def define_assertion_delegators
211
211
end
212
212
end
213
213
end
214
+
215
+ # Starting on Rails 4, Minitest is the default testing framework so no
216
+ # need to add TestUnit specific methods.
217
+ if ::Rails ::VERSION ::STRING >= '4.0.0'
218
+ def test_unit_specific_methods
219
+ [ ]
220
+ end
221
+ else
222
+ def test_unit_specific_methods
223
+ [ :build_message ]
224
+ end
225
+ end
214
226
end
215
227
216
228
class AssertionDelegator
Original file line number Diff line number Diff line change 25
25
it "does not expose Minitest's message method" do
26
26
expect ( methods ) . not_to include ( "message" )
27
27
end
28
+
29
+ if ::Rails ::VERSION ::STRING >= '4.0.0'
30
+ # In Ruby <= 1.8.7 Object#methods returns Strings instead of Symbols. They
31
+ # are all converted to Symbols to ensure we always compare them correctly.
32
+ it 'does not leak TestUnit specific methods into the AssertionDelegator' do
33
+ expect ( methods . map ( &:to_sym ) ) . to_not include ( :build_message )
34
+ end
35
+ else
36
+ it 'includes methods required by TestUnit into the AssertionDelegator' do
37
+ expect ( methods . map ( &:to_sym ) ) . to include ( :build_message )
38
+ end
39
+ end
28
40
end
You can’t perform that action at this time.
0 commit comments