test-unit 2.4.4 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,7 +86,7 @@ module Test
86
86
  end
87
87
 
88
88
  ##
89
- # Passes if +expected+ == +actual.
89
+ # Passes if +expected+ == +actual+.
90
90
  #
91
91
  # Note that the ordering of arguments is important, since a helpful
92
92
  # error message is generated when this one fails that tells you the
@@ -118,11 +118,7 @@ EOT
118
118
  begin
119
119
  assert_block(full_message) { expected == actual }
120
120
  rescue AssertionFailedError => failure
121
- failure.expected = expected
122
- failure.actual = actual
123
- failure.inspected_expected = AssertionMessage.convert(expected)
124
- failure.inspected_actual = AssertionMessage.convert(actual)
125
- failure.user_message = message
121
+ _set_failed_information(failure, expected, actual, message)
126
122
  raise failure # For JRuby. :<
127
123
  end
128
124
  end
@@ -149,11 +145,19 @@ EOT
149
145
  assert_expected_exception = Proc.new do |*_args|
150
146
  message, assert_exception_helper, actual_exception = _args
151
147
  expected = assert_exception_helper.expected_exceptions
148
+ diff = AssertionMessage.delayed_diff(expected, actual_exception)
152
149
  full_message = build_message(message,
153
- "<?> exception expected but was\n?",
154
- expected, actual_exception)
155
- assert_block(full_message) do
156
- expected == [] or assert_exception_helper.expected?(actual_exception)
150
+ "<?> exception expected but was\n<?>.?",
151
+ expected, actual_exception, diff)
152
+ begin
153
+ assert_block(full_message) do
154
+ expected == [] or
155
+ assert_exception_helper.expected?(actual_exception)
156
+ end
157
+ rescue AssertionFailedError => failure
158
+ _set_failed_information(failure, expected, actual_exception,
159
+ message)
160
+ raise failure # For JRuby. :<
157
161
  end
158
162
  end
159
163
  _assert_raise(assert_expected_exception, *args, &block)
@@ -183,7 +187,7 @@ EOT
183
187
  expected = assert_exception_helper.expected_exceptions
184
188
  full_message = build_message(message,
185
189
  "<?> family exception expected " +
186
- "but was\n?",
190
+ "but was\n<?>.",
187
191
  expected, actual_exception)
188
192
  assert_block(full_message) do
189
193
  assert_exception_helper.expected?(actual_exception, :kind_of?)
@@ -1423,6 +1427,15 @@ EOT
1423
1427
  end
1424
1428
  end
1425
1429
 
1430
+ private
1431
+ def _set_failed_information(failure, expected, actual, user_message)
1432
+ failure.expected = expected
1433
+ failure.actual = actual
1434
+ failure.inspected_expected = AssertionMessage.convert(expected)
1435
+ failure.inspected_actual = AssertionMessage.convert(actual)
1436
+ failure.user_message = user_message
1437
+ end
1438
+
1426
1439
  class AssertionMessage
1427
1440
  @use_pp = true
1428
1441
  class << self
@@ -1515,30 +1528,22 @@ EOT
1515
1528
  end
1516
1529
 
1517
1530
  def convert(object)
1518
- case object
1519
- when Exception
1520
- <<EOM.chop
1521
- Class: <#{convert(object.class)}>
1522
- Message: <#{convert(object.message)}>
1523
- ---Backtrace---
1524
- #{Util::BacktraceFilter.filter_backtrace(object.backtrace).join("\n")}
1525
- ---------------
1526
- EOM
1527
- else
1528
- inspector = Inspector.new(object)
1529
- if use_pp
1531
+ if object.is_a?(Exception)
1532
+ object = AssertExceptionHelper::WrappedException.new(object)
1533
+ end
1534
+ inspector = Inspector.new(object)
1535
+ if use_pp
1536
+ begin
1537
+ require 'pp' unless defined?(PP)
1530
1538
  begin
1531
- require 'pp' unless defined?(PP)
1532
- begin
1533
- return PP.pp(inspector, '').chomp
1534
- rescue NameError
1535
- end
1536
- rescue LoadError
1537
- self.use_pp = false
1539
+ return PP.pp(inspector, '').chomp
1540
+ rescue NameError
1538
1541
  end
1542
+ rescue LoadError
1543
+ self.use_pp = false
1539
1544
  end
1540
- inspector.inspect
1541
1545
  end
1546
+ inspector.inspect
1542
1547
  end
1543
1548
  end
1544
1549
 
@@ -1550,6 +1555,19 @@ EOM
1550
1555
  inspected_objects[object.object_id] ||=
1551
1556
  new(object, inspected_objects)
1552
1557
  end
1558
+
1559
+ @@inspector_classes = []
1560
+ def inspector_classes
1561
+ @@inspector_classes
1562
+ end
1563
+
1564
+ def register_inspector_class(inspector_class)
1565
+ @@inspector_classes << inspector_class
1566
+ end
1567
+
1568
+ def unregister_inspector_class(inspector_class)
1569
+ @@inspector_classes.delete(inspector_class)
1570
+ end
1553
1571
  end
1554
1572
 
1555
1573
  attr_reader :object
@@ -1583,17 +1601,18 @@ EOM
1583
1601
 
1584
1602
  private
1585
1603
  def inspect_target
1586
- if HashInspector.target?(@object)
1587
- HashInspector.new(@object, @inspected_objects)
1588
- elsif ArrayInspector.target?(@object)
1589
- ArrayInspector.new(@object, @inspected_objects)
1590
- else
1591
- @object
1604
+ self.class.inspector_classes.each do |inspector_class|
1605
+ if inspector_class.target?(@object)
1606
+ return inspector_class.new(@object, @inspected_objects)
1607
+ end
1592
1608
  end
1609
+ @object
1593
1610
  end
1594
1611
  end
1595
1612
 
1596
1613
  class HashInspector
1614
+ Inspector.register_inspector_class(self)
1615
+
1597
1616
  class << self
1598
1617
  def target?(object)
1599
1618
  object.is_a?(Hash) or object == ENV
@@ -1646,6 +1665,8 @@ EOM
1646
1665
  end
1647
1666
 
1648
1667
  class ArrayInspector
1668
+ Inspector.register_inspector_class(self)
1669
+
1649
1670
  class << self
1650
1671
  def target?(object)
1651
1672
  object.is_a?(Array)
@@ -1761,7 +1782,7 @@ EOM
1761
1782
  def to_s
1762
1783
  message_parts = []
1763
1784
  if (@head)
1764
- head = @head.to_s
1785
+ head = @head.to_s
1765
1786
  unless(head.empty?)
1766
1787
  message_parts << add_period(head)
1767
1788
  end
@@ -1774,13 +1795,14 @@ EOM
1774
1795
 
1775
1796
  class AssertExceptionHelper
1776
1797
  class WrappedException
1798
+ attr_reader :exception
1777
1799
  def initialize(exception)
1778
1800
  @exception = exception
1779
1801
  end
1780
1802
 
1781
1803
  def inspect
1782
1804
  if default_inspect?
1783
- "#{@exception.class.inspect}(#{@exception.message.inspect})"
1805
+ "#{@exception.class.inspect}(<#{@exception.message}>)"
1784
1806
  else
1785
1807
  @exception.inspect
1786
1808
  end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '2.4.4'
3
+ VERSION = '2.4.5'
4
4
  end
5
5
  end
@@ -10,18 +10,16 @@ require 'test/unit'
10
10
  module Test
11
11
  module Unit
12
12
  module AssertionCheckable
13
- backtrace_pre = "---Backtrace---"
14
- backtrace_post = "---------------"
15
- BACKTRACE_RE = /#{backtrace_pre}\n.+\n#{backtrace_post}/m
16
-
17
13
  private
18
14
  def check(value, message="")
19
15
  add_assertion
20
16
  raise AssertionFailedError.new(message) unless value
21
17
  end
22
18
 
23
- def check_assertions(expect_fail, expected_message="",
24
- return_value_expected=false)
19
+ def check_assertions(expect_fail, options={})
20
+ expected_message = options[:expected_message]
21
+ actual_message_normalizer = options[:actual_message_normalizer]
22
+ return_value_expected = options[:return_value_expected]
25
23
  @actual_assertion_count = 0
26
24
  failed = true
27
25
  actual_message = nil
@@ -48,14 +46,17 @@ module Test
48
46
  check(1 == @actual_assertion_count, message)
49
47
 
50
48
  if expect_fail
49
+ if actual_message_normalizer
50
+ actual_message = actual_message_normalizer.call(actual_message)
51
+ end
51
52
  case expected_message
52
53
  when String
53
- check(actual_message == expected_message,
54
+ check(expected_message == actual_message,
54
55
  "Should have the correct message.\n" +
55
56
  "<#{expected_message.inspect}> expected but was\n" +
56
57
  "<#{actual_message.inspect}>")
57
58
  when Regexp
58
- check(actual_message =~ expected_message,
59
+ check(expected_message =~ actual_message,
59
60
  "The message should match correctly.\n" +
60
61
  "</#{expected_message.source}/> expected to match\n" +
61
62
  "<#{actual_message.inspect}>")
@@ -76,11 +77,26 @@ module Test
76
77
  end
77
78
 
78
79
  def check_nothing_fails(return_value_expected=false, &proc)
79
- check_assertions(false, "", return_value_expected, &proc)
80
+ check_assertions(false,
81
+ {:expected_message => nil,
82
+ :return_value_expected => return_value_expected},
83
+ &proc)
80
84
  end
81
85
 
82
- def check_fails(expected_message="", &proc)
83
- check_assertions(true, expected_message, &proc)
86
+ def check_fail(expected_message, options={}, &proc)
87
+ check_assertions(true,
88
+ options.merge(:expected_message => expected_message),
89
+ &proc)
90
+ end
91
+
92
+ def check_fail_exception(expected_message, options={}, &proc)
93
+ normalizer = lambda do |actual_message|
94
+ actual_message.gsub(/(^[^:\n]+:\d+:.+\n?)+\z/, "")
95
+ end
96
+ check_assertions(true,
97
+ options.merge(:expected_message => expected_message,
98
+ :actual_message_normalizer => normalizer),
99
+ &proc)
84
100
  end
85
101
 
86
102
  def inspect_tag(tag)
@@ -121,10 +137,10 @@ module Test
121
137
  check_nothing_fails {
122
138
  assert_block("successful assert_block") {true}
123
139
  }
124
- check_fails("assert_block failed.") {
140
+ check_fail("assert_block failed.") {
125
141
  assert_block {false}
126
142
  }
127
- check_fails("failed assert_block") {
143
+ check_fail("failed assert_block") {
128
144
  assert_block("failed assert_block") {false}
129
145
  }
130
146
  end
@@ -147,7 +163,7 @@ diff:
147
163
  + string2
148
164
  ? ^
149
165
  EOM
150
- check_fails(message) {
166
+ check_fail(message) {
151
167
  assert_equal("string1", "string2")
152
168
  }
153
169
 
@@ -162,7 +178,7 @@ diff:
162
178
  + string2
163
179
  ? ^
164
180
  EOM
165
- check_fails(message) {
181
+ check_fail(message) {
166
182
  assert_equal("string1", "string2", "failed assert_equal")
167
183
  }
168
184
 
@@ -175,7 +191,7 @@ diff:
175
191
  ? - -
176
192
  + 111111
177
193
  EOM
178
- check_fails(message) do
194
+ check_fail(message) do
179
195
  assert_equal("111111", 111111)
180
196
  end
181
197
  end
@@ -216,7 +232,7 @@ folded diff:
216
232
  ? ^^^^^^^^^
217
233
  898123456789
218
234
  EOM
219
- check_fails(message) do
235
+ check_fail(message) do
220
236
  assert_equal(expected, actual)
221
237
  end
222
238
  end
@@ -226,7 +242,7 @@ EOM
226
242
  <1> expected but was
227
243
  <2>.
228
244
  EOM
229
- check_fails(message) do
245
+ check_fail(message) do
230
246
  assert_equal(1, 2)
231
247
  end
232
248
  end
@@ -238,7 +254,7 @@ EOM
238
254
  <#{now.inspect}> expected but was
239
255
  <#{now.inspect}>.
240
256
  EOM
241
- check_fails(message) do
257
+ check_fail(message) do
242
258
  assert_equal(now, now_without_usec)
243
259
  end
244
260
  end
@@ -253,7 +269,7 @@ diff:
253
269
  - a
254
270
  - b
255
271
  EOM
256
- check_fails(message) do
272
+ check_fail(message) do
257
273
  assert_equal("a\nb", "x")
258
274
  end
259
275
  end
@@ -274,7 +290,7 @@ folded diff:
274
290
  #{(["- " + ("x" * 78)] * 12).join("\n")}
275
291
  - #{"x" * 61}
276
292
  EOM
277
- check_fails(message) do
293
+ check_fail(message) do
278
294
  assert_equal("a\n" + "x" * 997, "x")
279
295
  end
280
296
 
@@ -282,7 +298,7 @@ EOM
282
298
  <#{("a\n" + "x" * 998).inspect}> expected but was
283
299
  <#{"x".inspect}>.
284
300
  EOM
285
- check_fails(message) do
301
+ check_fail(message) do
286
302
  assert_equal("a\n" + "x" * 998, "x")
287
303
  end
288
304
  end
@@ -307,7 +323,7 @@ folded diff:
307
323
  #{(["- " + ("x" * 78)]).join("\n")}
308
324
  - #{"x" * 19}
309
325
  EOM
310
- check_fails(message) do
326
+ check_fail(message) do
311
327
  assert_equal("a\n" + "x" * 97, "x")
312
328
  end
313
329
 
@@ -315,7 +331,7 @@ EOM
315
331
  <#{("a\n" + "x" * 98).inspect}> expected but was
316
332
  <#{"x".inspect}>.
317
333
  EOM
318
- check_fails(message) do
334
+ check_fail(message) do
319
335
  assert_equal("a\n" + "x" * 98, "x")
320
336
  end
321
337
  ensure
@@ -333,7 +349,7 @@ EOM
333
349
  <#{utf8_string.inspect}>("UTF-8") expected but was
334
350
  <#{ascii_8bit_string.inspect}>("ASCII-8BIT").
335
351
  EOM
336
- check_fails(message) do
352
+ check_fail(message) do
337
353
  assert_equal(utf8_string, ascii_8bit_string)
338
354
  end
339
355
  end
@@ -351,7 +367,7 @@ EOM
351
367
  <{"Lisp"=>"John McCarthy", "Ruby"=>"Matz"}> expected but was
352
368
  <{"Heavy"=>["C", "C++"], "LL"=>["Ruby", "Python"]}>.
353
369
  EOM
354
- check_fails(message) do
370
+ check_fail(message) do
355
371
  assert_equal(designers, categories)
356
372
  end
357
373
  end
@@ -371,7 +387,7 @@ diff:
371
387
  + {"followers"=>[{"followers"=>[{...}], "name"=>"Alice"}], "name"=>"Bob"}
372
388
  ? +++++++++++++++++
373
389
  EOM
374
- check_fails(message) do
390
+ check_fail(message) do
375
391
  assert_equal(alice, bob)
376
392
  end
377
393
  end
@@ -416,19 +432,18 @@ EOM
416
432
  end
417
433
 
418
434
  def test_assert_raise_fail
419
- check_fails("<RuntimeError> exception expected but none was thrown.") do
435
+ check_fail("<RuntimeError> exception expected but none was thrown.") do
420
436
  assert_raise(RuntimeError) do
421
437
  1 + 1
422
438
  end
423
439
  end
424
440
 
425
- message = <<-EOM
441
+ message = <<-EOM.chomp
426
442
  failed assert_raise.
427
443
  <ArgumentError> exception expected but was
428
- Class: <RuntimeError>
429
- Message: <"Error">
444
+ <RuntimeError(<Error>)>.
430
445
  EOM
431
- check_fails(/\A#{message}#{BACKTRACE_RE}\Z/m) do
446
+ check_fail_exception(message) do
432
447
  assert_raise(ArgumentError, "failed assert_raise") do
433
448
  raise "Error"
434
449
  end
@@ -438,7 +453,7 @@ EOM
438
453
  Should expect a class of exception, Object.
439
454
  <false> is not true.
440
455
  EOM
441
- check_fails(message.chomp) do
456
+ check_fail(message.chomp) do
442
457
  assert_nothing_raised(Object) do
443
458
  1 + 1
444
459
  end
@@ -478,21 +493,19 @@ EOM
478
493
  "from a successful assert_raise")
479
494
  end
480
495
 
481
- check_fails("<[ArgumentError, TypeError, Math, Comparable]> exception " +
496
+ check_fail("<[ArgumentError, TypeError, Math, Comparable]> exception " +
482
497
  "expected but none was thrown.") do
483
498
  assert_raise(*rescues) do
484
499
  1 + 1
485
500
  end
486
501
  end
487
502
 
488
- message = <<-EOM
503
+ message = <<-EOM.chomp
489
504
  failed assert_raise.
490
505
  <[ArgumentError, TypeError]> exception expected but was
491
- Class: <RuntimeError>
492
- Message: <"Error">
506
+ <RuntimeError(<Error>)>.
493
507
  EOM
494
- message = Regexp.escape(message)
495
- check_fails(/\A#{message}#{BACKTRACE_RE}\z/m) do
508
+ check_fail_exception(message) do
496
509
  assert_raise(ArgumentError, TypeError, "failed assert_raise") do
497
510
  raise "Error"
498
511
  end
@@ -513,25 +526,28 @@ EOM
513
526
  "Should have returned the correct exception " +
514
527
  "from a successful assert_raise")
515
528
 
516
- message = <<-EOM
517
- <RuntimeError("XXX")> exception expected but was
518
- Class: <RuntimeError>
519
- Message: <"Error">
529
+ message = <<-EOM.chomp
530
+ <RuntimeError(<XXX>)> exception expected but was
531
+ <RuntimeError(<Error>)>.
532
+
533
+ diff:
534
+ - RuntimeError(<XXX>)
535
+ ? ^^^
536
+ + RuntimeError(<Error>)
537
+ ? ^^^^^
520
538
  EOM
521
- message = Regexp.escape(message)
522
- check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
539
+ check_fail_exception(message) do
523
540
  return_value = assert_raise(RuntimeError.new("XXX")) do
524
541
  raise "Error"
525
542
  end
526
543
  end
527
544
 
528
545
  different_error_class = Class.new(StandardError)
529
- message = <<-EOM
530
- <\#<Class:[xa-f\\d]+>\\("Error"\\)> exception expected but was
531
- Class: <RuntimeError>
532
- Message: <"Error">
546
+ message = <<-EOM.chomp
547
+ <#{different_error_class.inspect}(<Error>)> exception expected but was
548
+ <RuntimeError(<Error>)>.
533
549
  EOM
534
- check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
550
+ check_fail_exception(message) do
535
551
  assert_raise(different_error_class.new("Error")) do
536
552
  raise "Error"
537
553
  end
@@ -541,12 +557,11 @@ EOM
541
557
  def different_error.inspect
542
558
  "DifferentError: \"Error\""
543
559
  end
544
- message = <<-EOM
545
- <\DifferentError: \\"Error\\"> exception expected but was
546
- Class: <RuntimeError>
547
- Message: <"Error">
560
+ message = <<-EOM.chomp
561
+ <DifferentError: "Error"> exception expected but was
562
+ <RuntimeError(<Error>)>.
548
563
  EOM
549
- check_fails(/\A#{message}#{BACKTRACE_RE}\z/) do
564
+ check_fail_exception(message) do
550
565
  assert_raise(different_error) do
551
566
  raise "Error"
552
567
  end
@@ -571,20 +586,20 @@ EOM
571
586
  check_nothing_fails {
572
587
  assert_instance_of(String, "string", "successful assert_instance_of")
573
588
  }
574
- check_fails(%Q{<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
589
+ check_fail(%Q{<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
575
590
  assert_instance_of(Hash, "string")
576
591
  }
577
- check_fails(%Q{failed assert_instance_of.\n<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
592
+ check_fail(%Q{failed assert_instance_of.\n<"string"> expected to be an instance of\n<Hash> but was\n<String>.}) {
578
593
  assert_instance_of(Hash, "string", "failed assert_instance_of")
579
594
  }
580
595
 
581
596
  check_nothing_fails do
582
597
  assert_instance_of([Fixnum, NilClass], 100)
583
598
  end
584
- check_fails(%Q{<"string"> expected to be an instance of\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
599
+ check_fail(%Q{<"string"> expected to be an instance of\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
585
600
  assert_instance_of([Fixnum, NilClass], "string")
586
601
  end
587
- check_fails(%Q{<100> expected to be an instance of\n[<Numeric>, <NilClass>] but was\n<Fixnum>.}) do
602
+ check_fail(%Q{<100> expected to be an instance of\n[<Numeric>, <NilClass>] but was\n<Fixnum>.}) do
588
603
  assert_instance_of([Numeric, NilClass], 100)
589
604
  end
590
605
  end
@@ -599,10 +614,10 @@ EOM
599
614
  check_nothing_fails {
600
615
  assert_nil(nil, "successful assert_nil")
601
616
  }
602
- check_fails(%Q{<"string"> expected to be nil.}) {
617
+ check_fail(%Q{<"string"> expected to be nil.}) {
603
618
  assert_nil("string")
604
619
  }
605
- check_fails(%Q{failed assert_nil.\n<"string"> expected to be nil.}) {
620
+ check_fail(%Q{failed assert_nil.\n<"string"> expected to be nil.}) {
606
621
  assert_nil("string", "failed assert_nil")
607
622
  }
608
623
  end
@@ -610,8 +625,8 @@ EOM
610
625
  def test_assert_not_nil
611
626
  check_nothing_fails{assert_not_nil(false)}
612
627
  check_nothing_fails{assert_not_nil(false, "message")}
613
- check_fails("<nil> expected to not be nil."){assert_not_nil(nil)}
614
- check_fails("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
628
+ check_fail("<nil> expected to not be nil."){assert_not_nil(nil)}
629
+ check_fail("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
615
630
  end
616
631
 
617
632
  def test_assert_kind_of
@@ -627,17 +642,17 @@ EOM
627
642
  check_nothing_fails {
628
643
  assert_kind_of(Comparable, 1)
629
644
  }
630
- check_fails(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
645
+ check_fail(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
631
646
  assert_kind_of(Class, "string")
632
647
  }
633
- check_fails(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
648
+ check_fail(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
634
649
  assert_kind_of(Class, "string", "failed assert_kind_of")
635
650
  }
636
651
 
637
652
  check_nothing_fails do
638
653
  assert_kind_of([Fixnum, NilClass], 100)
639
654
  end
640
- check_fails(%Q{<"string"> expected to be kind_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
655
+ check_fail(%Q{<"string"> expected to be kind_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
641
656
  assert_kind_of([Fixnum, NilClass], "string")
642
657
  end
643
658
  end
@@ -655,13 +670,13 @@ EOM
655
670
  check_nothing_fails {
656
671
  assert_match(/strin./, "string", "successful assert_match")
657
672
  }
658
- check_fails(%Q{<"string"> expected to be =~\n</slin./>.}) {
673
+ check_fail(%Q{<"string"> expected to be =~\n</slin./>.}) {
659
674
  assert_match(/slin./, "string")
660
675
  }
661
- check_fails(%Q{<"string"> expected to be =~\n</strin\\./>.}) {
676
+ check_fail(%Q{<"string"> expected to be =~\n</strin\\./>.}) {
662
677
  assert_match("strin.", "string")
663
678
  }
664
- check_fails(%Q{failed assert_match.\n<"string"> expected to be =~\n</slin./>.}) {
679
+ check_fail(%Q{failed assert_match.\n<"string"> expected to be =~\n</slin./>.}) {
665
680
  assert_match(/slin./, "string", "failed assert_match")
666
681
  }
667
682
  end
@@ -678,10 +693,10 @@ EOM
678
693
  assert_same(thing, thing, "successful assert_same")
679
694
  }
680
695
  thing2 = "thing"
681
- check_fails(%Q{<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
696
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
682
697
  assert_same(thing, thing2)
683
698
  }
684
- check_fails(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
699
+ check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
685
700
  assert_same(thing, thing2, "failed assert_same")
686
701
  }
687
702
  end
@@ -710,42 +725,55 @@ EOM
710
725
  rescue ZeroDivisionError
711
726
  end
712
727
  }
713
- check_fails("Should expect a class of exception, Object.\n<false> is not true.") {
728
+ check_fail("Should expect a class of exception, Object.\n<false> is not true.") {
714
729
  assert_nothing_raised(Object) {
715
730
  1 + 1
716
731
  }
717
732
  }
718
- check_fails(%r{\AException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
733
+ expected_message = <<-EOM.chomp
734
+ Exception raised:
735
+ RuntimeError(<Error>)
736
+ EOM
737
+ check_fail_exception(expected_message) {
719
738
  assert_nothing_raised {
720
739
  raise "Error"
721
740
  }
722
741
  }
723
- check_fails(%r{\Afailed assert_nothing_raised\.\nException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
742
+ expected_message = <<-EOM.chomp
743
+ failed assert_nothing_raised.
744
+ Exception raised:
745
+ RuntimeError(<Error>)
746
+ EOM
747
+ check_fail_exception(expected_message) {
724
748
  assert_nothing_raised("failed assert_nothing_raised") {
725
749
  raise "Error"
726
750
  }
727
751
  }
728
- check_fails(%r{\AException raised:\nClass: <RuntimeError>\nMessage: <"Error">\n---Backtrace---\n.+\n---------------\Z}m) {
752
+ expected_message = <<-EOM.chomp
753
+ Exception raised:
754
+ RuntimeError(<Error>)
755
+ EOM
756
+ check_fail_exception(expected_message) {
729
757
  assert_nothing_raised(StandardError, RuntimeError) {
730
758
  raise "Error"
731
759
  }
732
760
  }
733
- check_fails("Failure.") do
761
+ check_fail("Failure.") do
734
762
  assert_nothing_raised do
735
763
  flunk("Failure")
736
764
  end
737
765
  end
738
766
  end
739
-
767
+
740
768
  def test_flunk
741
- check_fails("Flunked.") {
769
+ check_fail("Flunked.") {
742
770
  flunk
743
771
  }
744
- check_fails("flunk message.") {
772
+ check_fail("flunk message.") {
745
773
  flunk("flunk message")
746
774
  }
747
775
  end
748
-
776
+
749
777
  def test_assert_not_same
750
778
  thing = "thing"
751
779
  thing2 = "thing"
@@ -755,10 +783,10 @@ EOM
755
783
  check_nothing_fails {
756
784
  assert_not_same(thing, thing2, "message")
757
785
  }
758
- check_fails(%Q{<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
786
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
759
787
  assert_not_same(thing, thing)
760
788
  }
761
- check_fails(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
789
+ check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
762
790
  assert_not_same(thing, thing, "message")
763
791
  }
764
792
  end
@@ -770,10 +798,10 @@ EOM
770
798
  check_nothing_fails {
771
799
  assert_not_equal("string1", "string2", "message")
772
800
  }
773
- check_fails(%Q{<"string"> expected to be != to\n<"string">.}) {
801
+ check_fail(%Q{<"string"> expected to be != to\n<"string">.}) {
774
802
  assert_not_equal("string", "string")
775
803
  }
776
- check_fails(%Q{message.\n<"string"> expected to be != to\n<"string">.}) {
804
+ check_fail(%Q{message.\n<"string"> expected to be != to\n<"string">.}) {
777
805
  assert_not_equal("string", "string", "message")
778
806
  }
779
807
  end
@@ -791,7 +819,7 @@ EOM
791
819
  end
792
820
 
793
821
  def test_assert_not_match_fail_not_regexp
794
- check_fails("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
822
+ check_fail("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
795
823
  "should be a Regexp.\n" +
796
824
  "<\"asdf\"> expected to be an instance of\n" +
797
825
  "<Regexp> but was\n" +
@@ -801,14 +829,14 @@ EOM
801
829
  end
802
830
 
803
831
  def test_assert_not_match_fail_match
804
- check_fails("</string/> expected to not match\n" +
832
+ check_fail("</string/> expected to not match\n" +
805
833
  "<\"string\">.") do
806
834
  assert_not_match(/string/, "string")
807
835
  end
808
836
  end
809
837
 
810
838
  def test_assert_not_match_fail_match_with_message
811
- check_fails("message.\n" +
839
+ check_fail("message.\n" +
812
840
  "</string/> expected to not match\n" +
813
841
  "<\"string\">.") do
814
842
  assert_not_match(/string/, "string", "message")
@@ -818,13 +846,13 @@ EOM
818
846
  def test_assert_no_match
819
847
  check_nothing_fails{assert_no_match(/sling/, "string")}
820
848
  check_nothing_fails{assert_no_match(/sling/, "string", "message")}
821
- check_fails(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> expected to be an instance of\n<Regexp> but was\n<String>.}) do
849
+ check_fail(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> expected to be an instance of\n<Regexp> but was\n<String>.}) do
822
850
  assert_no_match("asdf", "asdf")
823
851
  end
824
- check_fails(%Q{</string/> expected to not match\n<"string">.}) do
852
+ check_fail(%Q{</string/> expected to not match\n<"string">.}) do
825
853
  assert_no_match(/string/, "string")
826
854
  end
827
- check_fails(%Q{message.\n</string/> expected to not match\n<"string">.}) do
855
+ check_fail(%Q{message.\n</string/> expected to not match\n<"string">.}) do
828
856
  assert_no_match(/string/, "string", "message")
829
857
  end
830
858
  end
@@ -837,14 +865,14 @@ EOM
837
865
  end
838
866
 
839
867
  tag = :thing2
840
- check_fails("message.\n" +
868
+ check_fail("message.\n" +
841
869
  "<:thing> expected to be thrown but\n" +
842
870
  "<#{inspect_tag(tag)}> was thrown.") do
843
871
  assert_throw(:thing, "message") do
844
872
  throw :thing2
845
873
  end
846
874
  end
847
- check_fails("message.\n" +
875
+ check_fail("message.\n" +
848
876
  "<:thing> should have been thrown.") do
849
877
  assert_throw(:thing, "message") do
850
878
  1 + 1
@@ -861,7 +889,7 @@ EOM
861
889
 
862
890
  tag = :thing
863
891
  inspected = inspect_tag(tag)
864
- check_fails("message.\n" +
892
+ check_fail("message.\n" +
865
893
  "<#{inspected}> was thrown when nothing was expected.") do
866
894
  assert_nothing_thrown("message") do
867
895
  throw tag
@@ -873,10 +901,10 @@ EOM
873
901
  check_nothing_fails {
874
902
  assert_operator("thing", :==, "thing", "message")
875
903
  }
876
- check_fails(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
904
+ check_fail(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
877
905
  assert_operator("thing", 0.15, "thing")
878
906
  end
879
- check_fails(%Q{message.\n<"thing1"> expected to be\n==\n<"thing2">.}) {
907
+ check_fail(%Q{message.\n<"thing1"> expected to be\n==\n<"thing2">.}) {
880
908
  assert_operator("thing1", :==, "thing2", "message")
881
909
  }
882
910
  end
@@ -888,11 +916,11 @@ EOM
888
916
  check_nothing_fails {
889
917
  assert_respond_to("thing", "to_s", "message")
890
918
  }
891
- check_fails("<0.15>.kind_of?(Symbol) or\n" +
919
+ check_fail("<0.15>.kind_of?(Symbol) or\n" +
892
920
  "<0.15>.respond_to?(:to_str) expected") {
893
921
  assert_respond_to("thing", 0.15)
894
922
  }
895
- check_fails("message.\n" +
923
+ check_fail("message.\n" +
896
924
  "<:symbol>.respond_to?(:nonexistence) expected\n" +
897
925
  "(Class: <Symbol>)") {
898
926
  assert_respond_to(:symbol, :nonexistence, "message")
@@ -912,14 +940,14 @@ EOM
912
940
  end
913
941
 
914
942
  def test_assert_not_respond_to_fail_number
915
- check_fails("<0.15>.kind_of?(Symbol) or\n" +
943
+ check_fail("<0.15>.kind_of?(Symbol) or\n" +
916
944
  "<0.15>.respond_to?(:to_str) expected") do
917
945
  assert_respond_to("thing", 0.15)
918
946
  end
919
947
  end
920
948
 
921
949
  def tset_assert_not_respond_to_fail_existence
922
- check_fails("message.\n" +
950
+ check_fail("message.\n" +
923
951
  "!<:symbol>.respond_to?(:to_s) expected\n" +
924
952
  "(Class: <Symbol>)") do
925
953
  assert_respond_to(:symbol, :to_s, "message")
@@ -945,7 +973,7 @@ message.
945
973
  <return_argument(*[false, "bogus"])> with a true value but was
946
974
  <false>.
947
975
  EOM
948
- check_fails(expected_message.chomp) do
976
+ check_fail(expected_message.chomp) do
949
977
  assert_send([object, :return_argument, false, "bogus"], "message")
950
978
  end
951
979
  end
@@ -972,15 +1000,15 @@ EOM
972
1000
  assert_boolean(false)
973
1001
  end
974
1002
 
975
- check_fails("<true> or <false> expected but was\n<1>") do
1003
+ check_fail("<true> or <false> expected but was\n<1>") do
976
1004
  assert_boolean(1)
977
1005
  end
978
1006
 
979
- check_fails("<true> or <false> expected but was\n<nil>") do
1007
+ check_fail("<true> or <false> expected but was\n<nil>") do
980
1008
  assert_boolean(nil)
981
1009
  end
982
1010
 
983
- check_fails("message.\n<true> or <false> expected but was\n<\"XXX\">") do
1011
+ check_fail("message.\n<true> or <false> expected but was\n<\"XXX\">") do
984
1012
  assert_boolean("XXX", "message")
985
1013
  end
986
1014
  end
@@ -990,15 +1018,15 @@ EOM
990
1018
  assert_true(true)
991
1019
  end
992
1020
 
993
- check_fails("<true> expected but was\n<false>") do
1021
+ check_fail("<true> expected but was\n<false>") do
994
1022
  assert_true(false)
995
1023
  end
996
1024
 
997
- check_fails("<true> expected but was\n<1>") do
1025
+ check_fail("<true> expected but was\n<1>") do
998
1026
  assert_true(1)
999
1027
  end
1000
1028
 
1001
- check_fails("message.\n<true> expected but was\n<nil>") do
1029
+ check_fail("message.\n<true> expected but was\n<nil>") do
1002
1030
  assert_true(nil, "message")
1003
1031
  end
1004
1032
  end
@@ -1008,15 +1036,15 @@ EOM
1008
1036
  assert_false(false)
1009
1037
  end
1010
1038
 
1011
- check_fails("<false> expected but was\n<true>") do
1039
+ check_fail("<false> expected but was\n<true>") do
1012
1040
  assert_false(true)
1013
1041
  end
1014
1042
 
1015
- check_fails("<false> expected but was\n<nil>") do
1043
+ check_fail("<false> expected but was\n<nil>") do
1016
1044
  assert_false(nil)
1017
1045
  end
1018
1046
 
1019
- check_fails("message.\n<false> expected but was\n<:false>") do
1047
+ check_fail("message.\n<false> expected but was\n<:false>") do
1020
1048
  assert_false(:false, "message")
1021
1049
  end
1022
1050
  end
@@ -1043,7 +1071,7 @@ EOM
1043
1071
  <15> expected less than
1044
1072
  <10>.
1045
1073
  EOM
1046
- check_fails(expected_message.chomp) do
1074
+ check_fail(expected_message.chomp) do
1047
1075
  assert_compare(15, "<", 10)
1048
1076
  end
1049
1077
 
@@ -1052,7 +1080,7 @@ EOM
1052
1080
  <15> expected less than or equal to
1053
1081
  <10>.
1054
1082
  EOM
1055
- check_fails(expected_message.chomp) do
1083
+ check_fail(expected_message.chomp) do
1056
1084
  assert_compare(15, "<=", 10)
1057
1085
  end
1058
1086
 
@@ -1061,7 +1089,7 @@ EOM
1061
1089
  <10> expected greater than
1062
1090
  <15>.
1063
1091
  EOM
1064
- check_fails(expected_message.chomp) do
1092
+ check_fail(expected_message.chomp) do
1065
1093
  assert_compare(10, ">", 15)
1066
1094
  end
1067
1095
 
@@ -1070,7 +1098,7 @@ EOM
1070
1098
  <10> expected greater than or equal to
1071
1099
  <15>.
1072
1100
  EOM
1073
- check_fails(expected_message.chomp) do
1101
+ check_fail(expected_message.chomp) do
1074
1102
  assert_compare(10, ">=", 15)
1075
1103
  end
1076
1104
  end
@@ -1082,7 +1110,7 @@ EOM
1082
1110
  end
1083
1111
  end
1084
1112
 
1085
- check_fails("Failed assertion was expected.") do
1113
+ check_fail("Failed assertion was expected.") do
1086
1114
  assert_fail_assertion do
1087
1115
  end
1088
1116
  end
@@ -1111,7 +1139,7 @@ EOM
1111
1139
  <"Expected message"> exception message expected but was
1112
1140
  <"Actual message">.
1113
1141
  EOM
1114
- check_fails(expected_message.chomp) do
1142
+ check_fail(expected_message.chomp) do
1115
1143
  assert_raise_message("Expected message") do
1116
1144
  raise "Actual message"
1117
1145
  end
@@ -1120,7 +1148,7 @@ EOM
1120
1148
  expected_message = <<-EOM
1121
1149
  <"Expected message"> exception message expected but none was thrown.
1122
1150
  EOM
1123
- check_fails(expected_message.chomp) do
1151
+ check_fail(expected_message.chomp) do
1124
1152
  assert_raise_message("Expected message") do
1125
1153
  end
1126
1154
  end
@@ -1133,13 +1161,11 @@ EOM
1133
1161
  end
1134
1162
  end
1135
1163
 
1136
- expected_message = <<-EOM
1164
+ expected_message = <<-EOM.chomp
1137
1165
  <SystemCallError> family exception expected but was
1138
- Class: <RuntimeError>
1139
- Message: <"XXX">
1140
- ---Backtrace---
1166
+ <RuntimeError(<XXX>)>.
1141
1167
  EOM
1142
- check_fails(/\A#{Regexp.escape(expected_message)}(?m).+\z/) do
1168
+ check_fail_exception(expected_message) do
1143
1169
  assert_raise_kind_of(SystemCallError) do
1144
1170
  raise RuntimeError, "XXX"
1145
1171
  end
@@ -1155,7 +1181,7 @@ EOM
1155
1181
  assert_const_defined(Test, "Unit")
1156
1182
  end
1157
1183
 
1158
- check_fails("<Test>.const_defined?(<:Nonexistence>) expected.") do
1184
+ check_fail("<Test>.const_defined?(<:Nonexistence>) expected.") do
1159
1185
  assert_const_defined(Test, :Nonexistence)
1160
1186
  end
1161
1187
  end
@@ -1165,11 +1191,11 @@ EOM
1165
1191
  assert_not_const_defined(Test, :Nonexistence)
1166
1192
  end
1167
1193
 
1168
- check_fails("!<Test>.const_defined?(<:Unit>) expected.") do
1194
+ check_fail("!<Test>.const_defined?(<:Unit>) expected.") do
1169
1195
  assert_not_const_defined(Test, :Unit)
1170
1196
  end
1171
1197
 
1172
- check_fails("!<Test>.const_defined?(<\"Unit\">) expected.") do
1198
+ check_fail("!<Test>.const_defined?(<\"Unit\">) expected.") do
1173
1199
  assert_not_const_defined(Test, "Unit")
1174
1200
  end
1175
1201
  end
@@ -1179,11 +1205,11 @@ EOM
1179
1205
  assert_predicate([], :empty?)
1180
1206
  end
1181
1207
 
1182
- check_fails("<[1]>.empty? is true value expected but was\n<false>") do
1208
+ check_fail("<[1]>.empty? is true value expected but was\n<false>") do
1183
1209
  assert_predicate([1], :empty?)
1184
1210
  end
1185
1211
 
1186
- check_fails("<[1]>.respond_to?(:nonexistent?) expected\n" +
1212
+ check_fail("<[1]>.respond_to?(:nonexistent?) expected\n" +
1187
1213
  "(Class: <Array>)") do
1188
1214
  assert_predicate([1], :nonexistent?)
1189
1215
  end
@@ -1194,11 +1220,11 @@ EOM
1194
1220
  assert_not_predicate([1], :empty?)
1195
1221
  end
1196
1222
 
1197
- check_fails("<[]>.empty? is false value expected but was\n<true>") do
1223
+ check_fail("<[]>.empty? is false value expected but was\n<true>") do
1198
1224
  assert_not_predicate([], :empty?)
1199
1225
  end
1200
1226
 
1201
- check_fails("<[]>.respond_to?(:nonexistent?) expected\n" +
1227
+ check_fail("<[]>.respond_to?(:nonexistent?) expected\n" +
1202
1228
  "(Class: <Array>)") do
1203
1229
  assert_not_predicate([], :nonexistent?)
1204
1230
  end
@@ -1223,18 +1249,18 @@ EOM
1223
1249
  assert_alias_method(object, :original_method, :alias_method)
1224
1250
  end
1225
1251
 
1226
- check_fails("<#{object.method(:other).inspect}> is alias of\n" +
1252
+ check_fail("<#{object.method(:other).inspect}> is alias of\n" +
1227
1253
  "<#{object.method(:original_method).inspect}> expected") do
1228
1254
  assert_alias_method(object, :other, :original_method)
1229
1255
  end
1230
1256
 
1231
1257
  inspected_object = AssertionMessage.convert(object)
1232
- check_fails("<#{inspected_object}>.nonexistent doesn't exist\n" +
1258
+ check_fail("<#{inspected_object}>.nonexistent doesn't exist\n" +
1233
1259
  "(Class: <Object>)") do
1234
1260
  assert_alias_method(object, :nonexistent, :original_method)
1235
1261
  end
1236
1262
 
1237
- check_fails("<#{inspected_object}>.nonexistent doesn't exist\n" +
1263
+ check_fail("<#{inspected_object}>.nonexistent doesn't exist\n" +
1238
1264
  "(Class: <Object>)") do
1239
1265
  assert_alias_method(object, :alias_method, :nonexistent)
1240
1266
  end
@@ -1246,7 +1272,7 @@ EOM
1246
1272
  end
1247
1273
 
1248
1274
  nonexistent_file = __FILE__ + ".nonexistent"
1249
- check_fails("<#{nonexistent_file.inspect}> expected to exist") do
1275
+ check_fail("<#{nonexistent_file.inspect}> expected to exist") do
1250
1276
  assert_path_exist(nonexistent_file)
1251
1277
  end
1252
1278
  end
@@ -1257,7 +1283,7 @@ EOM
1257
1283
  assert_path_not_exist(nonexistent_file)
1258
1284
  end
1259
1285
 
1260
- check_fails("<#{__FILE__.inspect}> expected to not exist") do
1286
+ check_fail("<#{__FILE__.inspect}> expected to not exist") do
1261
1287
  assert_path_not_exist(__FILE__)
1262
1288
  end
1263
1289
  end
@@ -1285,26 +1311,26 @@ EOM
1285
1311
  end
1286
1312
 
1287
1313
  def test_fail_nil
1288
- check_fails("<nil> is not true.") do
1314
+ check_fail("<nil> is not true.") do
1289
1315
  assert(nil)
1290
1316
  end
1291
1317
  end
1292
1318
 
1293
1319
  def test_fail_false
1294
- check_fails("<false> is not true.") do
1320
+ check_fail("<false> is not true.") do
1295
1321
  assert(false)
1296
1322
  end
1297
1323
  end
1298
1324
 
1299
1325
  def test_fail_false_with_message
1300
- check_fails("failed assert.\n" +
1326
+ check_fail("failed assert.\n" +
1301
1327
  "<false> is not true.") do
1302
1328
  assert(false, "failed assert")
1303
1329
  end
1304
1330
  end
1305
1331
 
1306
1332
  def test_fail_with_assertion_message
1307
- check_fails("user message.\n" +
1333
+ check_fail("user message.\n" +
1308
1334
  "placeholder <:in> message") do
1309
1335
  assert(false, build_message("user message",
1310
1336
  "placeholder <?> message",
@@ -1313,7 +1339,7 @@ EOM
1313
1339
  end
1314
1340
 
1315
1341
  def test_error_invalid_message_true
1316
- check_fails("assertion message must be String, Proc or " +
1342
+ check_fail("assertion message must be String, Proc or " +
1317
1343
  "Test::Unit::Assertions::AssertionMessage: " +
1318
1344
  "<true>(<TrueClass>)") do
1319
1345
  begin
@@ -1363,7 +1389,7 @@ EOM
1363
1389
  end
1364
1390
 
1365
1391
  def test_fail_with_message
1366
- check_fails("message.\n" +
1392
+ check_fail("message.\n" +
1367
1393
  "<0.5> -/+ <0.05> expected to include\n" +
1368
1394
  "<0.4>.\n" +
1369
1395
  "\n" +
@@ -1376,7 +1402,7 @@ EOM
1376
1402
  def test_fail_because_not_float_like_object
1377
1403
  object = Object.new
1378
1404
  inspected_object = AssertionMessage.convert(object)
1379
- check_fails("The arguments must respond to to_f; " +
1405
+ check_fail("The arguments must respond to to_f; " +
1380
1406
  "the first float did not.\n" +
1381
1407
  "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1382
1408
  "(Class: <Object>)") do
@@ -1385,14 +1411,14 @@ EOM
1385
1411
  end
1386
1412
 
1387
1413
  def test_fail_because_negaitve_delta
1388
- check_fails("The delta should not be negative.\n" +
1414
+ check_fail("The delta should not be negative.\n" +
1389
1415
  "<-0.1> expected to be\n>=\n<0.0>.") do
1390
1416
  assert_in_delta(0.5, 0.4, -0.1, "message")
1391
1417
  end
1392
1418
  end
1393
1419
 
1394
1420
  def test_fail_without_delta
1395
- check_fails("<1.402> -/+ <0.001> expected to include\n" +
1421
+ check_fail("<1.402> -/+ <0.001> expected to include\n" +
1396
1422
  "<1.404>.\n" +
1397
1423
  "\n" +
1398
1424
  "Relation:\n" +
@@ -1444,7 +1470,7 @@ EOM
1444
1470
  end
1445
1471
 
1446
1472
  def test_fail
1447
- check_fails("<1.4> -/+ <0.11> expected to not include\n" +
1473
+ check_fail("<1.4> -/+ <0.11> expected to not include\n" +
1448
1474
  "<1.5>.\n" +
1449
1475
  "\n" +
1450
1476
  "Relation:\n" +
@@ -1458,7 +1484,7 @@ EOM
1458
1484
  end
1459
1485
 
1460
1486
  def test_fail_without_delta
1461
- check_fails("<1.402> -/+ <0.001> expected to not include\n" +
1487
+ check_fail("<1.402> -/+ <0.001> expected to not include\n" +
1462
1488
  "<1.4021>.\n" +
1463
1489
  "\n" +
1464
1490
  "Relation:\n" +
@@ -1472,7 +1498,7 @@ EOM
1472
1498
  end
1473
1499
 
1474
1500
  def test_fail_with_message
1475
- check_fails("message.\n" +
1501
+ check_fail("message.\n" +
1476
1502
  "<0.5> -/+ <0.11> expected to not include\n" +
1477
1503
  "<0.4>.\n" +
1478
1504
  "\n" +
@@ -1489,7 +1515,7 @@ EOM
1489
1515
  def test_fail_because_not_float_like_object
1490
1516
  object = Object.new
1491
1517
  inspected_object = AssertionMessage.convert(object)
1492
- check_fails("The arguments must respond to to_f; " +
1518
+ check_fail("The arguments must respond to to_f; " +
1493
1519
  "the first float did not.\n" +
1494
1520
  "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1495
1521
  "(Class: <Object>)") do
@@ -1498,7 +1524,7 @@ EOM
1498
1524
  end
1499
1525
 
1500
1526
  def test_fail_because_negaitve_delta
1501
- check_fails("The delta should not be negative.\n" +
1527
+ check_fail("The delta should not be negative.\n" +
1502
1528
  "<-0.11> expected to be\n>=\n<0.0>.") do
1503
1529
  assert_not_in_delta(0.5, 0.4, -0.11, "message")
1504
1530
  end
@@ -1549,7 +1575,7 @@ EOM
1549
1575
  end
1550
1576
 
1551
1577
  def test_fail_with_message
1552
- check_fails("message.\n" +
1578
+ check_fail("message.\n" +
1553
1579
  "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1554
1580
  "expected to include\n" +
1555
1581
  "<8999>.\n" +
@@ -1567,7 +1593,7 @@ EOM
1567
1593
  def test_fail_because_not_float_like_object
1568
1594
  object = Object.new
1569
1595
  inspected_object = AssertionMessage.convert(object)
1570
- check_fails("The arguments must respond to to_f; " +
1596
+ check_fail("The arguments must respond to to_f; " +
1571
1597
  "the first float did not.\n" +
1572
1598
  "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1573
1599
  "(Class: <Object>)") do
@@ -1576,14 +1602,14 @@ EOM
1576
1602
  end
1577
1603
 
1578
1604
  def test_fail_because_negaitve_epsilon
1579
- check_fails("The epsilon should not be negative.\n" +
1605
+ check_fail("The epsilon should not be negative.\n" +
1580
1606
  "<-0.1> expected to be\n>=\n<0.0>.") do
1581
1607
  assert_in_epsilon(10000, 9000, -0.1, "message")
1582
1608
  end
1583
1609
  end
1584
1610
 
1585
1611
  def test_fail_without_epsilon
1586
- check_fails("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1612
+ check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1587
1613
  "expected to include\n" +
1588
1614
  "<10011>.\n" +
1589
1615
  "\n" +
@@ -1636,7 +1662,7 @@ EOM
1636
1662
  end
1637
1663
 
1638
1664
  def test_fail
1639
- check_fails("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1665
+ check_fail("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1640
1666
  "expected to not include\n" +
1641
1667
  "<9000>.\n" +
1642
1668
  "\n" +
@@ -1651,7 +1677,7 @@ EOM
1651
1677
  end
1652
1678
 
1653
1679
  def test_fail_without_epsilon
1654
- check_fails("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1680
+ check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1655
1681
  "expected to not include\n" +
1656
1682
  "<9990>.\n" +
1657
1683
  "\n" +
@@ -1666,7 +1692,7 @@ EOM
1666
1692
  end
1667
1693
 
1668
1694
  def test_fail_with_message
1669
- check_fails("message.\n" +
1695
+ check_fail("message.\n" +
1670
1696
  "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1671
1697
  "expected to not include\n" +
1672
1698
  "<9000>.\n" +
@@ -1684,7 +1710,7 @@ EOM
1684
1710
  def test_fail_because_not_float_like_object
1685
1711
  object = Object.new
1686
1712
  inspected_object = AssertionMessage.convert(object)
1687
- check_fails("The arguments must respond to to_f; " +
1713
+ check_fail("The arguments must respond to to_f; " +
1688
1714
  "the first float did not.\n" +
1689
1715
  "<#{inspected_object}>.respond_to?(:to_f) expected\n" +
1690
1716
  "(Class: <Object>)") do
@@ -1693,7 +1719,7 @@ EOM
1693
1719
  end
1694
1720
 
1695
1721
  def test_fail_because_negaitve_epsilon
1696
- check_fails("The epsilon should not be negative.\n" +
1722
+ check_fail("The epsilon should not be negative.\n" +
1697
1723
  "<-0.1> expected to be\n>=\n<0.0>.") do
1698
1724
  assert_not_in_epsilon(10000, 9000, -0.1, "message")
1699
1725
  end
@@ -1716,14 +1742,14 @@ EOM
1716
1742
  end
1717
1743
 
1718
1744
  def test_fail
1719
- check_fails("<[1, 2, 3]> expected to include\n" +
1745
+ check_fail("<[1, 2, 3]> expected to include\n" +
1720
1746
  "<4>.") do
1721
1747
  assert_include([1, 2, 3], 4)
1722
1748
  end
1723
1749
  end
1724
1750
 
1725
1751
  def test_fail_with_message
1726
- check_fails("message.\n" +
1752
+ check_fail("message.\n" +
1727
1753
  "<[1, 2, 3]> expected to include\n" +
1728
1754
  "<4>.") do
1729
1755
  assert_include([1, 2, 3], 4, "message")
@@ -1733,7 +1759,7 @@ EOM
1733
1759
  def test_fail_because_not_collection_like_object
1734
1760
  object = Object.new
1735
1761
  inspected_object = AssertionMessage.convert(object)
1736
- check_fails("The collection must respond to :include?.\n" +
1762
+ check_fail("The collection must respond to :include?.\n" +
1737
1763
  "<#{inspected_object}>.respond_to?(:include?) expected\n" +
1738
1764
  "(Class: <Object>)") do
1739
1765
  assert_include(object, 1)
@@ -1757,14 +1783,14 @@ EOM
1757
1783
  end
1758
1784
 
1759
1785
  def test_fail
1760
- check_fails("<[1, 2, 3]> expected to not include\n" +
1786
+ check_fail("<[1, 2, 3]> expected to not include\n" +
1761
1787
  "<2>.") do
1762
1788
  assert_not_include([1, 2, 3], 2)
1763
1789
  end
1764
1790
  end
1765
1791
 
1766
1792
  def test_fail_with_message
1767
- check_fails("message.\n" +
1793
+ check_fail("message.\n" +
1768
1794
  "<[1, 2, 3]> expected to not include\n" +
1769
1795
  "<2>.") do
1770
1796
  assert_not_include([1, 2, 3], 2, "message")
@@ -1774,7 +1800,7 @@ EOM
1774
1800
  def test_fail_because_not_collection_like_object
1775
1801
  object = Object.new
1776
1802
  inspected_object = AssertionMessage.convert(object)
1777
- check_fails("The collection must respond to :include?.\n" +
1803
+ check_fail("The collection must respond to :include?.\n" +
1778
1804
  "<#{inspected_object}>.respond_to?(:include?) expected\n" +
1779
1805
  "(Class: <Object>)") do
1780
1806
  assert_not_include(object, 1)
@@ -1798,13 +1824,13 @@ EOM
1798
1824
  end
1799
1825
 
1800
1826
  def test_fail
1801
- check_fails("<[1]> expected to be empty.") do
1827
+ check_fail("<[1]> expected to be empty.") do
1802
1828
  assert_empty([1])
1803
1829
  end
1804
1830
  end
1805
1831
 
1806
1832
  def test_fail_with_message
1807
- check_fails("message.\n" +
1833
+ check_fail("message.\n" +
1808
1834
  "<[1]> expected to be empty.") do
1809
1835
  assert_empty([1], "message")
1810
1836
  end
@@ -1813,7 +1839,7 @@ EOM
1813
1839
  def test_fail_because_no_empty_method
1814
1840
  object = Object.new
1815
1841
  inspected_object = AssertionMessage.convert(object)
1816
- check_fails("The object must respond to :empty?.\n" +
1842
+ check_fail("The object must respond to :empty?.\n" +
1817
1843
  "<#{inspected_object}>.respond_to?(:empty?) expected\n" +
1818
1844
  "(Class: <Object>)") do
1819
1845
  assert_empty(object)
@@ -1837,13 +1863,13 @@ EOM
1837
1863
  end
1838
1864
 
1839
1865
  def test_fail
1840
- check_fails("<[]> expected to not be empty.") do
1866
+ check_fail("<[]> expected to not be empty.") do
1841
1867
  assert_not_empty([])
1842
1868
  end
1843
1869
  end
1844
1870
 
1845
1871
  def test_fail_with_message
1846
- check_fails("message.\n" +
1872
+ check_fail("message.\n" +
1847
1873
  "<[]> expected to not be empty.") do
1848
1874
  assert_not_empty([], "message")
1849
1875
  end
@@ -1852,7 +1878,7 @@ EOM
1852
1878
  def test_fail_because_no_empty_method
1853
1879
  object = Object.new
1854
1880
  inspected_object = AssertionMessage.convert(object)
1855
- check_fails("The object must respond to :empty?.\n" +
1881
+ check_fail("The object must respond to :empty?.\n" +
1856
1882
  "<#{inspected_object}>.respond_to?(:empty?) expected\n" +
1857
1883
  "(Class: <Object>)") do
1858
1884
  assert_not_empty(object)
@@ -1876,7 +1902,7 @@ message.
1876
1902
  <member?(*[2])> with not a true value but was
1877
1903
  <true>.
1878
1904
  EOM
1879
- check_fails(expected_message.chomp) do
1905
+ check_fail(expected_message.chomp) do
1880
1906
  assert_not_send([[1, 2], :member?, 2], "message")
1881
1907
  end
1882
1908
  end