minitest 5.20.0 → 5.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,14 @@
1
- # encoding: UTF-8
2
-
3
1
  require "minitest/autorun"
4
-
5
- if defined? Encoding then
6
- e = Encoding.default_external
7
- if e != Encoding::UTF_8 then
8
- warn ""
9
- warn ""
10
- warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
11
- warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
12
- warn ""
13
- warn ""
14
- end
2
+ require_relative "metametameta"
3
+
4
+ e = Encoding.default_external
5
+ if e != Encoding::UTF_8 then
6
+ warn ""
7
+ warn ""
8
+ warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
9
+ warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
10
+ warn ""
11
+ warn ""
15
12
  end
16
13
 
17
14
  SomeError = Class.new Exception
@@ -26,14 +23,11 @@ class TestMinitestAssertions < Minitest::Test
26
23
  # which is not threadsafe. Nearly every method in here is an
27
24
  # assertion test so it isn't worth splitting it out further.
28
25
 
29
- RUBY18 = !defined? Encoding
30
-
31
26
  # not included in JRuby
32
27
  RE_LEVELS = /\(\d+ levels\) /
33
28
 
34
29
  class DummyTest
35
30
  include Minitest::Assertions
36
- # include Minitest::Reportable # TODO: why do I really need this?
37
31
 
38
32
  attr_accessor :assertions, :failure
39
33
 
@@ -58,15 +52,6 @@ class TestMinitestAssertions < Minitest::Test
58
52
  "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}")
59
53
  end
60
54
 
61
- def assert_deprecated name
62
- dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
63
- dep = "" if $-w.nil?
64
-
65
- assert_output nil, dep do
66
- yield
67
- end
68
- end
69
-
70
55
  def assert_triggered expected, klass = Minitest::Assertion
71
56
  e = assert_raises klass do
72
57
  yield
@@ -88,10 +73,6 @@ class TestMinitestAssertions < Minitest::Test
88
73
  end
89
74
  end
90
75
 
91
- def clean s
92
- s.gsub(/^ {6,10}/, "")
93
- end
94
-
95
76
  def non_verbose
96
77
  orig_verbose = $VERBOSE
97
78
  $VERBOSE = false
@@ -144,36 +125,43 @@ class TestMinitestAssertions < Minitest::Test
144
125
  end
145
126
 
146
127
  def test_assert_equal_different_collection_array_hex_invisible
147
- object1 = Object.new
148
- object2 = Object.new
149
- msg = "No visible difference in the Array#inspect output.
128
+ exp = Object.new
129
+ act = Object.new
130
+ msg = <<~EOM.chomp
131
+ No visible difference in the Array#inspect output.
150
132
  You should look at the implementation of #== on Array or its members.
151
- [#<Object:0xXXXXXX>]".gsub(/^ +/, "")
133
+ [#<Object:0xXXXXXX>]
134
+ EOM
152
135
  assert_triggered msg do
153
- @tc.assert_equal [object1], [object2]
136
+ @tc.assert_equal [exp], [act]
154
137
  end
155
138
  end
156
139
 
157
140
  def test_assert_equal_different_collection_hash_hex_invisible
158
- h1, h2 = {}, {}
159
- h1[1] = Object.new
160
- h2[1] = Object.new
161
- msg = "No visible difference in the Hash#inspect output.
141
+ exp, act = {}, {}
142
+ exp[1] = Object.new
143
+ act[1] = Object.new
144
+ act_obj = act[1]
145
+ # TODO: switch to endless when 2.7 is dropped
146
+ act_obj.define_singleton_method(:inspect) { "#<Object:0xXXXXXX>" }
147
+ msg = <<~EOM.chomp % [act]
148
+ No visible difference in the Hash#inspect output.
162
149
  You should look at the implementation of #== on Hash or its members.
163
- {1=>#<Object:0xXXXXXX>}".gsub(/^ +/, "")
150
+ %p
151
+ EOM
164
152
 
165
153
  assert_triggered msg do
166
- @tc.assert_equal h1, h2
154
+ @tc.assert_equal exp, act
167
155
  end
168
156
  end
169
157
 
170
158
  def test_assert_equal_different_diff_deactivated
171
159
  without_diff do
172
160
  assert_triggered util_msg("haha" * 10, "blah" * 10) do
173
- o1 = "haha" * 10
174
- o2 = "blah" * 10
161
+ exp = "haha" * 10
162
+ act = "blah" * 10
175
163
 
176
- @tc.assert_equal o1, o2
164
+ @tc.assert_equal exp, act
177
165
  end
178
166
  end
179
167
  end
@@ -195,78 +183,84 @@ class TestMinitestAssertions < Minitest::Test
195
183
  def initialize s; @name = s; end
196
184
  end
197
185
 
198
- o1 = c.new "a"
199
- o2 = c.new "b"
200
- msg = clean <<-EOS
186
+ exp = c.new "a"
187
+ act = c.new "b"
188
+ msg = <<~EOS
201
189
  --- expected
202
190
  +++ actual
203
191
  @@ -1 +1 @@
204
- -#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\">
205
- +#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
192
+ -#<#<Class:0xXXXXXX>:0xXXXXXX @name="a">
193
+ +#<#<Class:0xXXXXXX>:0xXXXXXX @name="b">
206
194
  EOS
207
195
 
208
196
  assert_triggered msg do
209
- @tc.assert_equal o1, o2
197
+ @tc.assert_equal exp, act
210
198
  end
211
199
  end
212
200
 
213
201
  def test_assert_equal_different_hex_invisible
214
- o1 = Object.new
215
- o2 = Object.new
202
+ exp = Object.new
203
+ act = Object.new
216
204
 
217
- msg = "No visible difference in the Object#inspect output.
205
+ msg = <<~EOM.chomp
206
+ No visible difference in the Object#inspect output.
218
207
  You should look at the implementation of #== on Object or its members.
219
- #<Object:0xXXXXXX>".gsub(/^ +/, "")
208
+ #<Object:0xXXXXXX>
209
+ EOM
220
210
 
221
211
  assert_triggered msg do
222
- @tc.assert_equal o1, o2
212
+ @tc.assert_equal exp, act
223
213
  end
224
214
  end
225
215
 
226
216
  def test_assert_equal_different_long
227
- msg = "--- expected
217
+ msg = <<~EOM
218
+ --- expected
228
219
  +++ actual
229
220
  @@ -1 +1 @@
230
- -\"hahahahahahahahahahahahahahahahahahahaha\"
231
- +\"blahblahblahblahblahblahblahblahblahblah\"
232
- ".gsub(/^ +/, "")
221
+ -"hahahahahahahahahahahahahahahahahahahaha"
222
+ +"blahblahblahblahblahblahblahblahblahblah"
223
+ EOM
233
224
 
234
225
  assert_triggered msg do
235
- o1 = "haha" * 10
236
- o2 = "blah" * 10
226
+ exp = "haha" * 10
227
+ act = "blah" * 10
237
228
 
238
- @tc.assert_equal o1, o2
229
+ @tc.assert_equal exp, act
239
230
  end
240
231
  end
241
232
 
242
233
  def test_assert_equal_different_long_invisible
243
- msg = "No visible difference in the String#inspect output.
234
+ msg = <<~EOM.chomp
235
+ No visible difference in the String#inspect output.
244
236
  You should look at the implementation of #== on String or its members.
245
- \"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
237
+ "blahblahblahblahblahblahblahblahblahblah"
238
+ EOM
246
239
 
247
240
  assert_triggered msg do
248
- o1 = "blah" * 10
249
- o2 = "blah" * 10
250
- def o1.== _
241
+ exp = "blah" * 10
242
+ act = "blah" * 10
243
+ def exp.== _
251
244
  false
252
245
  end
253
- @tc.assert_equal o1, o2
246
+ @tc.assert_equal exp, act
254
247
  end
255
248
  end
256
249
 
257
250
  def test_assert_equal_different_long_msg
258
- msg = "message.
251
+ msg = <<~EOM
252
+ message.
259
253
  --- expected
260
254
  +++ actual
261
255
  @@ -1 +1 @@
262
- -\"hahahahahahahahahahahahahahahahahahahaha\"
263
- +\"blahblahblahblahblahblahblahblahblahblah\"
264
- ".gsub(/^ +/, "")
256
+ -"hahahahahahahahahahahahahahahahahahahaha"
257
+ +"blahblahblahblahblahblahblahblahblahblah"
258
+ EOM
265
259
 
266
260
  assert_triggered msg do
267
- o1 = "haha" * 10
268
- o2 = "blah" * 10
269
- @tc.assert_equal o1, o2, "message"
261
+ exp = "haha" * 10
262
+ act = "blah" * 10
263
+ @tc.assert_equal exp, act, "message"
270
264
  end
271
265
  end
272
266
 
@@ -290,7 +284,7 @@ class TestMinitestAssertions < Minitest::Test
290
284
  end
291
285
 
292
286
  def test_assert_equal_does_not_allow_lhs_nil
293
- if Minitest::VERSION =~ /^6/ then
287
+ if Minitest::VERSION >= "6" then
294
288
  warn "Time to strip the MT5 test"
295
289
 
296
290
  @assertion_count += 1
@@ -301,7 +295,7 @@ class TestMinitestAssertions < Minitest::Test
301
295
  err_re = /Use assert_nil if expecting nil from .*test_minitest_\w+.rb/
302
296
  err_re = "" if $-w.nil?
303
297
 
304
- assert_output "", err_re do
298
+ assert_deprecation err_re do
305
299
  @tc.assert_equal nil, nil
306
300
  end
307
301
  end
@@ -314,29 +308,23 @@ class TestMinitestAssertions < Minitest::Test
314
308
  end
315
309
 
316
310
  def test_assert_equal_string_bug791
317
- exp = <<-'EOF'.gsub(/^ {10}/, "") # note single quotes
318
- --- expected
319
- +++ actual
320
- @@ -1,2 +1 @@
321
- -"\\n
322
- -"
323
- +"\\\"
324
- EOF
325
-
326
- exp = "Expected: \"\\\\n\"\n Actual: \"\\\\\""
311
+ exp = <<~EOM.chomp
312
+ Expected: "\\\\n"
313
+ Actual: "\\\\"
314
+ EOM
327
315
  assert_triggered exp do
328
316
  @tc.assert_equal "\\n", "\\"
329
317
  end
330
318
  end
331
319
 
332
320
  def test_assert_equal_string_both_escaped_unescaped_newlines
333
- msg = <<-EOM.gsub(/^ {10}/, "")
321
+ msg = <<~EOM
334
322
  --- expected
335
323
  +++ actual
336
324
  @@ -1,2 +1 @@
337
- -\"A\\n
338
- -B\"
339
- +\"A\\n\\\\nB\"
325
+ -"A\\n
326
+ -B"
327
+ +"A\\n\\\\nB"
340
328
  EOM
341
329
 
342
330
  assert_triggered msg do
@@ -348,7 +336,7 @@ class TestMinitestAssertions < Minitest::Test
348
336
  end
349
337
 
350
338
  def test_assert_equal_string_encodings
351
- msg = <<-EOM.gsub(/^ {10}/, "")
339
+ msg = <<~EOM
352
340
  --- expected
353
341
  +++ actual
354
342
  @@ -1,3 +1,3 @@
@@ -360,14 +348,14 @@ class TestMinitestAssertions < Minitest::Test
360
348
  EOM
361
349
 
362
350
  assert_triggered msg do
363
- x = "bad-utf8-\xF1.txt"
364
- y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
365
- @tc.assert_equal x, y
351
+ exp = "bad-utf8-\xF1.txt"
352
+ act = exp.dup.b
353
+ @tc.assert_equal exp, act
366
354
  end
367
- end unless RUBY18
355
+ end
368
356
 
369
357
  def test_assert_equal_string_encodings_both_different
370
- msg = <<-EOM.gsub(/^ {10}/, "")
358
+ msg = <<~EOM
371
359
  --- expected
372
360
  +++ actual
373
361
  @@ -1,3 +1,3 @@
@@ -379,14 +367,14 @@ class TestMinitestAssertions < Minitest::Test
379
367
  EOM
380
368
 
381
369
  assert_triggered msg do
382
- x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
383
- y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
384
- @tc.assert_equal x, y
370
+ exp = "bad-utf8-\xF1.txt".dup.force_encoding Encoding::ASCII
371
+ act = exp.dup.b
372
+ @tc.assert_equal exp, act
385
373
  end
386
- end unless RUBY18
374
+ end
387
375
 
388
376
  def test_assert_equal_unescape_newlines
389
- msg = <<-'EOM'.gsub(/^ {10}/, "") # NOTE single quotes on heredoc
377
+ msg = <<~'EOM' # NOTE single quotes on heredoc
390
378
  --- expected
391
379
  +++ actual
392
380
  @@ -1,2 +1,2 @@
@@ -438,7 +426,7 @@ class TestMinitestAssertions < Minitest::Test
438
426
  end
439
427
 
440
428
  def test_assert_in_epsilon_triggered_negative_case
441
- x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
429
+ x = "0.100000xxx"
442
430
  y = "0.1"
443
431
  assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
444
432
  @tc.assert_in_epsilon(-1.1, -1, 0.1)
@@ -728,6 +716,7 @@ class TestMinitestAssertions < Minitest::Test
728
716
  end
729
717
  end
730
718
  end
719
+
731
720
  def test_assert_predicate
732
721
  @tc.assert_predicate "", :empty?
733
722
  end
@@ -757,17 +746,18 @@ class TestMinitestAssertions < Minitest::Test
757
746
  end
758
747
  end
759
748
 
760
- expected = clean <<-EOM.chomp
749
+ expected = <<~EOM.chomp
761
750
  [StandardError] exception expected, not
762
751
  Class: <SomeError>
763
- Message: <\"blah\">
752
+ Message: <"blah">
764
753
  ---Backtrace---
765
- FILE:LINE:in \`block in test_assert_raises_default_triggered\'
754
+ FILE:LINE:in 'block in test_assert_raises_default_triggered'
766
755
  ---------------
767
756
  EOM
768
757
 
769
758
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
770
- actual.gsub!(RE_LEVELS, "") unless jruby?
759
+ actual.gsub! RE_LEVELS, "" unless jruby?
760
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
771
761
 
772
762
  assert_equal expected, actual
773
763
  end
@@ -836,17 +826,18 @@ class TestMinitestAssertions < Minitest::Test
836
826
  end
837
827
  end
838
828
 
839
- expected = clean <<-EOM
829
+ expected = <<~EOM
840
830
  [SomeError] exception expected, not
841
831
  Class: <AnError>
842
- Message: <\"some message\">
832
+ Message: <"some message">
843
833
  ---Backtrace---
844
- FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
834
+ FILE:LINE:in 'block in test_assert_raises_subclass_triggered'
845
835
  ---------------
846
836
  EOM
847
837
 
848
838
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
849
- actual.gsub!(RE_LEVELS, "") unless jruby?
839
+ actual.gsub! RE_LEVELS, "" unless jruby?
840
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
850
841
 
851
842
  assert_equal expected.chomp, actual
852
843
  end
@@ -858,17 +849,18 @@ class TestMinitestAssertions < Minitest::Test
858
849
  end
859
850
  end
860
851
 
861
- expected = clean <<-EOM.chomp
852
+ expected = <<~EOM.chomp
862
853
  [RuntimeError] exception expected, not
863
854
  Class: <SyntaxError>
864
- Message: <\"icky\">
855
+ Message: <"icky">
865
856
  ---Backtrace---
866
- FILE:LINE:in \`block in test_assert_raises_triggered_different\'
857
+ FILE:LINE:in 'block in test_assert_raises_triggered_different'
867
858
  ---------------
868
859
  EOM
869
860
 
870
861
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
871
- actual.gsub!(RE_LEVELS, "") unless jruby?
862
+ actual.gsub! RE_LEVELS, "" unless jruby?
863
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
872
864
 
873
865
  assert_equal expected, actual
874
866
  end
@@ -880,18 +872,19 @@ class TestMinitestAssertions < Minitest::Test
880
872
  end
881
873
  end
882
874
 
883
- expected = clean <<-EOM
875
+ expected = <<~EOM
884
876
  XXX.
885
877
  [RuntimeError] exception expected, not
886
878
  Class: <SyntaxError>
887
- Message: <\"icky\">
879
+ Message: <"icky">
888
880
  ---Backtrace---
889
- FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
881
+ FILE:LINE:in 'block in test_assert_raises_triggered_different_msg'
890
882
  ---------------
891
883
  EOM
892
884
 
893
885
  actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
894
- actual.gsub!(RE_LEVELS, "") unless jruby?
886
+ actual.gsub! RE_LEVELS, "" unless jruby?
887
+ actual.gsub!(/[`']block in (?:TestMinitestAssertions#)?/, "'block in ")
895
888
 
896
889
  assert_equal expected.chomp, actual
897
890
  end
@@ -936,6 +929,16 @@ class TestMinitestAssertions < Minitest::Test
936
929
  end
937
930
  end
938
931
 
932
+ def test_assert_respond_to__include_all
933
+ @tc.assert_respond_to @tc, :exit, include_all: true
934
+ end
935
+
936
+ def test_assert_respond_to__include_all_triggered
937
+ assert_triggered(/Expected .+::DummyTest. to respond to #exit\?/) do
938
+ @tc.assert_respond_to @tc, :exit?, include_all: true
939
+ end
940
+ end
941
+
939
942
  def test_assert_same
940
943
  @assertion_count = 3
941
944
 
@@ -952,8 +955,8 @@ class TestMinitestAssertions < Minitest::Test
952
955
  @tc.assert_same 1, 2
953
956
  end
954
957
 
955
- s1 = "blah"
956
- s2 = "blah"
958
+ s1 = +"blah"
959
+ s2 = +"blah"
957
960
 
958
961
  assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
959
962
  @tc.assert_same s1, s2
@@ -961,16 +964,24 @@ class TestMinitestAssertions < Minitest::Test
961
964
  end
962
965
 
963
966
  def test_assert_send
964
- assert_deprecated :assert_send do
967
+ @assertion_count = 0 if error_on_warn?
968
+ assert_deprecation(/DEPRECATED: assert_send/) do
965
969
  @tc.assert_send [1, :<, 2]
966
970
  end
967
971
  end
968
972
 
969
973
  def test_assert_send_bad
970
- assert_deprecated :assert_send do
971
- assert_triggered "Expected 1.>(*[2]) to return true." do
974
+ if error_on_warn? then
975
+ @assertion_count = 0
976
+ assert_deprecation(/DEPRECATED: assert_send/) do
972
977
  @tc.assert_send [1, :>, 2]
973
978
  end
979
+ else
980
+ assert_triggered "Expected 1.>(*[2]) to return true." do
981
+ assert_deprecation(/DEPRECATED: assert_send/) do
982
+ @tc.assert_send [1, :>, 2]
983
+ end
984
+ end
974
985
  end
975
986
  end
976
987
 
@@ -1141,8 +1152,8 @@ class TestMinitestAssertions < Minitest::Test
1141
1152
 
1142
1153
  non_verbose do
1143
1154
  out, err = capture_subprocess_io do
1144
- system("echo hi")
1145
- system("echo bye! 1>&2")
1155
+ system "echo hi"
1156
+ system "echo bye! 1>&2"
1146
1157
  end
1147
1158
 
1148
1159
  assert_equal "hi\n", out
@@ -1153,18 +1164,14 @@ class TestMinitestAssertions < Minitest::Test
1153
1164
  def test_class_asserts_match_refutes
1154
1165
  @assertion_count = 0
1155
1166
 
1156
- methods = Minitest::Assertions.public_instance_methods
1157
- methods.map!(&:to_s) if Symbol === methods.first
1167
+ methods = Minitest::Assertions.public_instance_methods.map(&:to_s)
1158
1168
 
1159
1169
  # These don't have corresponding refutes _on purpose_. They're
1160
1170
  # useless and will never be added, so don't bother.
1161
1171
  ignores = %w[assert_output assert_raises assert_send
1162
1172
  assert_silent assert_throws assert_mock]
1163
1173
 
1164
- # These are test/unit methods. I'm not actually sure why they're still here
1165
- ignores += %w[assert_no_match assert_not_equal assert_not_nil
1166
- assert_not_same assert_nothing_raised
1167
- assert_nothing_thrown assert_raise]
1174
+ ignores += %w[assert_allocations] # for minitest-gcstats
1168
1175
 
1169
1176
  asserts = methods.grep(/^assert/).sort - ignores
1170
1177
  refutes = methods.grep(/^refute/).sort - ignores
@@ -1444,6 +1451,16 @@ class TestMinitestAssertions < Minitest::Test
1444
1451
  end
1445
1452
  end
1446
1453
 
1454
+ def test_refute_respond_to__include_all
1455
+ @tc.refute_respond_to "blah", :missing, include_all: true
1456
+ end
1457
+
1458
+ def test_refute_respond_to__include_all_triggered
1459
+ assert_triggered(/Expected .*DummyTest.* to not respond to exit./) do
1460
+ @tc.refute_respond_to @tc, :exit, include_all: true
1461
+ end
1462
+ end
1463
+
1447
1464
  def test_refute_same
1448
1465
  @tc.refute_same 1, 2
1449
1466
  end
@@ -1482,7 +1499,7 @@ class TestMinitestAssertions < Minitest::Test
1482
1499
  d0 = Time.now
1483
1500
  d1 = d0 + 86_400 # I am an idiot
1484
1501
 
1485
- assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
1502
+ assert_deprecation(/Stale skip_until \"not yet\" at .*?:\d+$/) do
1486
1503
  assert_skip_until d0, "not yet"
1487
1504
  end
1488
1505
 
@@ -1529,9 +1546,11 @@ class TestMinitestAssertionHelpers < Minitest::Test
1529
1546
  end
1530
1547
 
1531
1548
  def test_diff_equal
1532
- msg = "No visible difference in the String#inspect output.
1549
+ msg = <<~EOM.chomp
1550
+ No visible difference in the String#inspect output.
1533
1551
  You should look at the implementation of #== on String or its members.
1534
- \"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
1552
+ "blahblahblahblahblahblahblahblahblahblah"
1553
+ EOM
1535
1554
 
1536
1555
  o1 = "blah" * 10
1537
1556
  o2 = "blah" * 10
@@ -1543,7 +1562,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1543
1562
  end
1544
1563
 
1545
1564
  def test_diff_str_mixed
1546
- msg = <<-'EOM'.gsub(/^ {10}/, "") # NOTE single quotes on heredoc
1565
+ msg = <<~'EOM' # NOTE single quotes on heredoc
1547
1566
  --- expected
1548
1567
  +++ actual
1549
1568
  @@ -1 +1 @@
@@ -1558,7 +1577,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1558
1577
  end
1559
1578
 
1560
1579
  def test_diff_str_multiline
1561
- msg = <<-'EOM'.gsub(/^ {10}/, "") # NOTE single quotes on heredoc
1580
+ msg = <<~EOM
1562
1581
  --- expected
1563
1582
  +++ actual
1564
1583
  @@ -1,2 +1,2 @@
@@ -1574,7 +1593,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1574
1593
  end
1575
1594
 
1576
1595
  def test_diff_str_simple
1577
- msg = <<-'EOM'.gsub(/^ {10}/, "").chomp # NOTE single quotes on heredoc
1596
+ msg = <<~EOM.chomp
1578
1597
  Expected: "A"
1579
1598
  Actual: "B"
1580
1599
  EOM
@@ -1626,14 +1645,14 @@ class TestMinitestAssertionHelpers < Minitest::Test
1626
1645
  end
1627
1646
 
1628
1647
  def test_mu_pp_for_diff_str_bad_encoding
1629
- str = "\666".force_encoding Encoding::UTF_8
1648
+ str = "\666".dup.force_encoding Encoding::UTF_8
1630
1649
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1631
1650
 
1632
1651
  assert_mu_pp_for_diff exp, str, :raw
1633
1652
  end
1634
1653
 
1635
1654
  def test_mu_pp_for_diff_str_bad_encoding_both
1636
- str = "\666A\\n\nB".force_encoding Encoding::UTF_8
1655
+ str = "\666A\\n\nB".dup.force_encoding Encoding::UTF_8
1637
1656
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6A\\\\n\\nB\""
1638
1657
 
1639
1658
  assert_mu_pp_for_diff exp, str, :raw
@@ -1680,7 +1699,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
1680
1699
  end
1681
1700
 
1682
1701
  def test_mu_pp_str_bad_encoding
1683
- str = "\666".force_encoding Encoding::UTF_8
1702
+ str = "\666".dup.force_encoding Encoding::UTF_8
1684
1703
  exp = "# encoding: UTF-8\n# valid: false\n\"\\xB6\""
1685
1704
 
1686
1705
  assert_mu_pp exp, str, :raw
@@ -17,7 +17,7 @@ class TestMinitestBenchmark < Minitest::Test
17
17
  def test_cls_runnable_methods
18
18
  assert_equal [], Minitest::Benchmark.runnable_methods
19
19
 
20
- c = Class.new(Minitest::Benchmark) do
20
+ c = Class.new Minitest::Benchmark do
21
21
  def bench_blah
22
22
  end
23
23
  end