test-unit 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,70 @@ module Test
49
49
  @current_attributes = kept_attributes
50
50
  end
51
51
 
52
+ # Set an attribute to test methods.
53
+ #
54
+ # @overload attribute(name, value)
55
+ # @example
56
+ # attribute :speed, :slow
57
+ # def test_my_slow_method
58
+ # self[:speed] # => :slow
59
+ # end
60
+ #
61
+ # @param [Object] name the attribute name
62
+ # @param [Object] value the attribute value
63
+ # @return [void]
64
+ #
65
+ # @overload attribute(name, value, *method_names)
66
+ # @example
67
+ # def test_my_slow_method1
68
+ # self[:speed] # => :slow
69
+ # end
70
+ #
71
+ # attribute :speed, :slow, :test_my_slow_method1, :test_my_slow_method2
72
+ #
73
+ # def test_my_slow_method2
74
+ # self[:speed] # => :slow
75
+ # end
76
+ #
77
+ # @param [Object] name the attribute name
78
+ # @param [Object] value the attribute value
79
+ # @param [Array<Symbol, String>] method_names the test method names set the attribute
80
+ # @return [void]
81
+ #
82
+ # @overload attribute(name, value, options)
83
+ # @example
84
+ # attribute :speed, :slow, keep: true
85
+ # def test_my_slow_method1
86
+ # self[:speed] # => :slow
87
+ # end
88
+ #
89
+ # def test_my_slow_method2
90
+ # self[:speed] # => :slow
91
+ # end
92
+ #
93
+ # @param [Object] name the attribute name
94
+ # @param [Object] value the attribute value
95
+ # @option options [Boolean] :keep whether or not to set attribute to following test methods
96
+ # @return [void]
97
+ #
98
+ # @overload attribute(name, value, options, *method_names)
99
+ # @example
100
+ # def test_my_slow_method1
101
+ # self[:speed] # => :slow
102
+ # end
103
+ #
104
+ # # There are no valid options for now.
105
+ # attribute :speed, :slow, {}, :test_my_slow_method1
106
+ #
107
+ # def test_my_slow_method2
108
+ # self[:speed] # => nil
109
+ # end
110
+ #
111
+ # @param [Object] name the attribute name
112
+ # @param [Object] value the attribute value
113
+ # @param [Hash] options ignored
114
+ # @param [Array<Symbol, String>] method_names the test method names set the attribute
115
+ # @return [void]
52
116
  def attribute(name, value, options={}, *method_names)
53
117
  unless options.is_a?(Hash)
54
118
  method_names << options
@@ -246,10 +246,7 @@ module Test
246
246
  name = (%r{\A/(.*)/\Z} =~ name ? Regexp.new($1) : name)
247
247
  @filters << lambda do |test|
248
248
  return true if name === test.method_name
249
- test_name_without_class_name = test.name.gsub(/\(.+?\)\z/, "")
250
- if test_name_without_class_name != test.method_name
251
- return true if name === test_name_without_class_name
252
- end
249
+ return true if name === test.local_name
253
250
  false
254
251
  end
255
252
  end
@@ -82,6 +82,25 @@ module Test
82
82
  # 1. cleanup
83
83
  # 1. teardown
84
84
  # 1. shutdown
85
+ #
86
+ # You can set an attribute to each test.
87
+ #
88
+ # Example:
89
+ #
90
+ # class TestMyClass < Test::Unit::TestCase
91
+ # attribute :speed, :fast
92
+ # def test_my_fast_method
93
+ # # You can get the attribute via `self[]`
94
+ # self[:speed] # => :fast
95
+ # ...
96
+ # end
97
+ #
98
+ # attribute :speed, :slow
99
+ # def test_my_slow_method
100
+ # self[:speed] # => :slow
101
+ # ...
102
+ # end
103
+ # end
85
104
  class TestCase
86
105
  include Attribute
87
106
  include Fixture
@@ -320,7 +339,7 @@ module Test
320
339
  # the same in meaning:
321
340
  #
322
341
  # Standard:
323
- # class TestParent < Test::UnitTestCase
342
+ # class TestParent < Test::Unit::TestCase
324
343
  # class TestChild < self
325
344
  # def test_in_child
326
345
  # end
@@ -328,7 +347,7 @@ module Test
328
347
  # end
329
348
  #
330
349
  # Syntax sugar:
331
- # class TestParent < Test::UnitTestCase
350
+ # class TestParent < Test::Unit::TestCase
332
351
  # sub_test_case("TestChild") do
333
352
  # def test_in_child
334
353
  # end
@@ -394,7 +413,8 @@ module Test
394
413
  end
395
414
  if query_method_name
396
415
  available_location = available_locations.find do |location|
397
- query_method_name == location[:method_name]
416
+ location[:test_case] == self and
417
+ query_method_name == location[:method_name]
398
418
  end
399
419
  return [] if available_location.nil?
400
420
  available_locations = [available_location]
@@ -661,10 +681,19 @@ module Test
661
681
  # Returns a human-readable name for the specific test that
662
682
  # this instance of TestCase represents.
663
683
  def name
684
+ "#{local_name}(#{self.class.name})"
685
+ end
686
+
687
+ # Returns a human-readable name for the specific test that this
688
+ # instance of TestCase represents.
689
+ #
690
+ # `#local_name` doesn't include class name. `#name` includes
691
+ # class name.
692
+ def local_name
664
693
  if @internal_data.have_test_data?
665
- "#{@method_name}[#{data_label}](#{self.class.name})"
694
+ "#{@method_name}[#{data_label}]"
666
695
  else
667
- "#{@method_name}(#{self.class.name})"
696
+ @method_name.to_s
668
697
  end
669
698
  end
670
699
 
@@ -745,7 +774,7 @@ module Test
745
774
  signature = "#{self.class}\##{@method_name}"
746
775
  redefined_info = self[:redefined]
747
776
  if redefined_info
748
- notify("#{signature} was redefined",
777
+ notify("<#{signature}> was redefined",
749
778
  :backtrace => redefined_info[:backtrace])
750
779
  end
751
780
  if @internal_data.have_test_data?
@@ -757,7 +786,7 @@ module Test
757
786
  backtrace = locations.collect do |location|
758
787
  "#{location[:path]}:#{location[:line]}"
759
788
  end
760
- notify("#{signature} misses a parameter to take test data",
789
+ notify("<#{signature}> misses a parameter to take test data",
761
790
  :backtrace => backtrace)
762
791
  end
763
792
  else
@@ -342,7 +342,7 @@ module Test
342
342
  def test_started(test)
343
343
  return unless output?(VERBOSE)
344
344
 
345
- name = test.name.sub(/\(.+?\)\z/, '')
345
+ name = test.local_name
346
346
  right_space = 8 * 2
347
347
  left_space = @progress_row_max - right_space
348
348
  left_space = left_space - indent.size - name.size
@@ -473,8 +473,12 @@ module Test
473
473
  fault_class.name.split(/::/).last.downcase
474
474
  end
475
475
 
476
+ def fault_class_color(fault_class)
477
+ color(fault_class_color_name(fault_class))
478
+ end
479
+
476
480
  def fault_color(fault)
477
- color(fault_class_color_name(fault.class))
481
+ fault_class_color(fault.class)
478
482
  end
479
483
 
480
484
  def fault_marker_color(fault)
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = "3.2.3"
3
+ VERSION = "3.2.4"
4
4
  end
5
5
  end
@@ -301,8 +301,8 @@ EOM
301
301
 
302
302
  def test_multi_lines_result
303
303
  message = <<-EOM.chomp
304
- <#{"a\nb".inspect}> expected but was
305
- <#{"x".inspect}>.
304
+ <#{AssertionMessage.convert("a\nb")}> expected but was
305
+ <#{AssertionMessage.convert("x")}>.
306
306
 
307
307
  diff:
308
308
  + x
@@ -316,8 +316,8 @@ EOM
316
316
 
317
317
  def test_large_string
318
318
  message = <<-EOM.chomp
319
- <#{("a\n" + "x" * 997).inspect}> expected but was
320
- <#{"x".inspect}>.
319
+ <#{AssertionMessage.convert("a\n" + "x" * 997)}> expected but was
320
+ <#{AssertionMessage.convert("x")}>.
321
321
 
322
322
  diff:
323
323
  + x
@@ -335,8 +335,8 @@ EOM
335
335
  end
336
336
 
337
337
  message = <<-EOM.chomp
338
- <#{("a\n" + "x" * 998).inspect}> expected but was
339
- <#{"x".inspect}>.
338
+ <#{AssertionMessage.convert("a\n" + "x" * 998)}> expected but was
339
+ <#{AssertionMessage.convert("x")}>.
340
340
  EOM
341
341
  check_fail(message) do
342
342
  assert_equal("a\n" + "x" * 998, "x")
@@ -349,8 +349,8 @@ EOM
349
349
  ENV[key] = "100"
350
350
  begin
351
351
  message = <<-EOM.chomp
352
- <#{("a\n" + "x" * 97).inspect}> expected but was
353
- <#{"x".inspect}>.
352
+ <#{AssertionMessage.convert("a\n" + "x" * 97)}> expected but was
353
+ <#{AssertionMessage.convert("x")}>.
354
354
 
355
355
  diff:
356
356
  + x
@@ -368,8 +368,8 @@ EOM
368
368
  end
369
369
 
370
370
  message = <<-EOM.chomp
371
- <#{("a\n" + "x" * 98).inspect}> expected but was
372
- <#{"x".inspect}>.
371
+ <#{AssertionMessage.convert("a\n" + "x" * 98)}> expected but was
372
+ <#{AssertionMessage.convert("x")}>.
373
373
  EOM
374
374
  check_fail(message) do
375
375
  assert_equal("a\n" + "x" * 98, "x")
@@ -495,7 +495,7 @@ EOM
495
495
  end
496
496
 
497
497
  def test_assert_raise_fail
498
- check_fail("<RuntimeError> exception expected but none was thrown.") do
498
+ check_fail("<RuntimeError> exception was expected but none was thrown.") do
499
499
  assert_raise(RuntimeError) do
500
500
  1 + 1
501
501
  end
@@ -556,7 +556,7 @@ EOM
556
556
  end
557
557
 
558
558
  check_fail("<[ArgumentError, TypeError, Math, Comparable]> exception " +
559
- "expected but none was thrown.") do
559
+ "was expected but none was thrown.") do
560
560
  assert_raise(*rescues) do
561
561
  1 + 1
562
562
  end
@@ -663,21 +663,21 @@ EOM
663
663
  check_nothing_fails {
664
664
  assert_instance_of(String, "string", "successful assert_instance_of")
665
665
  }
666
- check_fail(%Q{<"string"> expected to be instance_of?\n<Hash> but was\n<String>.}) {
666
+ check_fail(%Q{<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
667
667
  assert_instance_of(Hash, "string")
668
668
  }
669
- check_fail(%Q{failed assert_instance_of.\n<"string"> expected to be instance_of?\n<Hash> but was\n<String>.}) {
669
+ check_fail(%Q{failed assert_instance_of.\n<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
670
670
  assert_instance_of(Hash, "string", "failed assert_instance_of")
671
671
  }
672
672
 
673
673
  check_nothing_fails do
674
- assert_instance_of([Fixnum, NilClass], 100)
674
+ assert_instance_of([Class, NilClass], Array)
675
675
  end
676
- check_fail(%Q{<"string"> expected to be instance_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
677
- assert_instance_of([Fixnum, NilClass], "string")
676
+ check_fail(%Q{<"string"> was expected to be instance_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
677
+ assert_instance_of([Class, NilClass], "string")
678
678
  end
679
- check_fail(%Q{<100> expected to be instance_of?\n[<Numeric>, <NilClass>] but was\n<Fixnum>.}) do
680
- assert_instance_of([Numeric, NilClass], 100)
679
+ check_fail(%Q{<Array> was expected to be instance_of?\n[<Module>, <NilClass>] but was\n<Class>.}) do
680
+ assert_instance_of([Module, NilClass], Array)
681
681
  end
682
682
  end
683
683
 
@@ -688,20 +688,20 @@ EOM
688
688
  check_nothing_fails {
689
689
  assert_not_instance_of(NilClass, "string", "successful assert_instance_of")
690
690
  }
691
- check_fail(%Q{<"string"> expected to not be instance_of?\n<String> but was.}) {
691
+ check_fail(%Q{<"string"> was expected to not be instance_of?\n<String> but was.}) {
692
692
  assert_not_instance_of(String, "string")
693
693
  }
694
- check_fail(%Q{failed assert.\n<"string"> expected to not be instance_of?\n<String> but was.}) {
694
+ check_fail(%Q{failed assert.\n<"string"> was expected to not be instance_of?\n<String> but was.}) {
695
695
  assert_not_instance_of(String, "string", "failed assert")
696
696
  }
697
697
 
698
698
  check_nothing_fails do
699
- assert_not_instance_of([Numeric, NilClass], 100)
699
+ assert_not_instance_of([Module, NilClass], Array)
700
700
  end
701
- check_fail(%Q{<100> expected to not be instance_of?\n[<Fixnum>, <NilClass>] but was.}) do
702
- assert_not_instance_of([Fixnum, NilClass], 100)
701
+ check_fail(%Q{<Array> was expected to not be instance_of?\n[<Class>, <NilClass>] but was.}) do
702
+ assert_not_instance_of([Class, NilClass], Array)
703
703
  end
704
- check_fail(%Q{<"str"> expected to not be instance_of?\n[<Numeric>, <String>] but was.}) do
704
+ check_fail(%Q{<"str"> was expected to not be instance_of?\n[<Numeric>, <String>] but was.}) do
705
705
  assert_not_instance_of([Numeric, String], 'str')
706
706
  end
707
707
  end
@@ -716,10 +716,10 @@ EOM
716
716
  check_nothing_fails {
717
717
  assert_nil(nil, "successful assert_nil")
718
718
  }
719
- check_fail(%Q{<"string"> expected to be nil.}) {
719
+ check_fail(%Q{<"string"> was expected to be nil.}) {
720
720
  assert_nil("string")
721
721
  }
722
- check_fail(%Q{failed assert_nil.\n<"string"> expected to be nil.}) {
722
+ check_fail(%Q{failed assert_nil.\n<"string"> was expected to be nil.}) {
723
723
  assert_nil("string", "failed assert_nil")
724
724
  }
725
725
  end
@@ -727,8 +727,8 @@ EOM
727
727
  def test_assert_not_nil
728
728
  check_nothing_fails{assert_not_nil(false)}
729
729
  check_nothing_fails{assert_not_nil(false, "message")}
730
- check_fail("<nil> expected to not be nil."){assert_not_nil(nil)}
731
- check_fail("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
730
+ check_fail("<nil> was expected to not be nil."){assert_not_nil(nil)}
731
+ check_fail("message.\n<nil> was expected to not be nil.") {assert_not_nil(nil, "message")}
732
732
  end
733
733
 
734
734
  def test_assert_kind_of
@@ -744,18 +744,18 @@ EOM
744
744
  check_nothing_fails {
745
745
  assert_kind_of(Comparable, 1)
746
746
  }
747
- check_fail(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
747
+ check_fail(%Q{<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
748
748
  assert_kind_of(Class, "string")
749
749
  }
750
- check_fail(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
750
+ check_fail(%Q{failed assert_kind_of.\n<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
751
751
  assert_kind_of(Class, "string", "failed assert_kind_of")
752
752
  }
753
753
 
754
754
  check_nothing_fails do
755
- assert_kind_of([Fixnum, NilClass], 100)
755
+ assert_kind_of([Class, NilClass], Array)
756
756
  end
757
- check_fail(%Q{<"string"> expected to be kind_of?\n[<Fixnum>, <NilClass>] but was\n<String>.}) do
758
- assert_kind_of([Fixnum, NilClass], "string")
757
+ check_fail(%Q{<"string"> was expected to be kind_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
758
+ assert_kind_of([Class, NilClass], "string")
759
759
  end
760
760
  end
761
761
 
@@ -769,18 +769,18 @@ EOM
769
769
  check_nothing_fails {
770
770
  assert_not_kind_of(Integer, 1.1)
771
771
  }
772
- check_fail(%Q{<1> expected to not be kind_of?\n<Integer> but was.}) {
772
+ check_fail(%Q{<1> was expected to not be kind_of?\n<Integer> but was.}) {
773
773
  assert_not_kind_of(Integer, 1)
774
774
  }
775
- check_fail(%Q{failed assert_not_kind_of.\n<"string"> expected to not be kind_of?\n<String> but was.}) {
775
+ check_fail(%Q{failed assert_not_kind_of.\n<"string"> was expected to not be kind_of?\n<String> but was.}) {
776
776
  assert_not_kind_of(String, "string", "failed assert_not_kind_of")
777
777
  }
778
778
 
779
779
  check_nothing_fails do
780
780
  assert_not_kind_of([String, NilClass], 100)
781
781
  end
782
- check_fail(%Q{<100> expected to not be kind_of?\n[<Fixnum>, <NilClass>] but was.}) do
783
- assert_not_kind_of([Fixnum, NilClass], 100)
782
+ check_fail(%Q{<Array> was expected to not be kind_of?\n[<Class>, <NilClass>] but was.}) do
783
+ assert_not_kind_of([Class, NilClass], Array)
784
784
  end
785
785
  end
786
786
 
@@ -797,13 +797,13 @@ EOM
797
797
  check_nothing_fails {
798
798
  assert_match(/strin./, "string", "successful assert_match")
799
799
  }
800
- check_fail(%Q{</slin./> expected to be =~\n<"string">.}) {
800
+ check_fail(%Q{</slin./> was expected to be =~\n<"string">.}) {
801
801
  assert_match(/slin./, "string")
802
802
  }
803
- check_fail(%Q{</strin\\./> expected to be =~\n<"string">.}) {
803
+ check_fail(%Q{</strin\\./> was expected to be =~\n<"string">.}) {
804
804
  assert_match("strin.", "string")
805
805
  }
806
- check_fail(%Q{failed assert_match.\n</slin./> expected to be =~\n<"string">.}) {
806
+ check_fail(%Q{failed assert_match.\n</slin./> was expected to be =~\n<"string">.}) {
807
807
  assert_match(/slin./, "string", "failed assert_match")
808
808
  }
809
809
  end
@@ -820,10 +820,10 @@ EOM
820
820
  assert_same(thing, thing, "successful assert_same")
821
821
  }
822
822
  thing2 = "thing"
823
- check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
823
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
824
824
  assert_same(thing, thing2)
825
825
  }
826
- check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
826
+ check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
827
827
  assert_same(thing, thing2, "failed assert_same")
828
828
  }
829
829
  end
@@ -913,10 +913,10 @@ EOM
913
913
  check_nothing_fails {
914
914
  assert_not_same(thing, thing2, "message")
915
915
  }
916
- check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
916
+ check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
917
917
  assert_not_same(thing, thing)
918
918
  }
919
- check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
919
+ check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
920
920
  assert_not_same(thing, thing, "message")
921
921
  }
922
922
  end
@@ -928,10 +928,10 @@ EOM
928
928
  check_nothing_fails {
929
929
  assert_not_equal("string1", "string2", "message")
930
930
  }
931
- check_fail(%Q{<"string"> expected to be != to\n<"string">.}) {
931
+ check_fail(%Q{<"string"> was expected to be != to\n<"string">.}) {
932
932
  assert_not_equal("string", "string")
933
933
  }
934
- check_fail(%Q{message.\n<"string"> expected to be != to\n<"string">.}) {
934
+ check_fail(%Q{message.\n<"string"> was expected to be != to\n<"string">.}) {
935
935
  assert_not_equal("string", "string", "message")
936
936
  }
937
937
  end
@@ -951,7 +951,7 @@ EOM
951
951
  def test_assert_not_match_fail_not_regexp
952
952
  check_fail("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
953
953
  "should be a Regexp.\n" +
954
- "<\"asdf\"> expected to be instance_of?\n" +
954
+ "<\"asdf\"> was expected to be instance_of?\n" +
955
955
  "<Regexp> but was\n" +
956
956
  "<String>.") do
957
957
  assert_not_match("asdf", "asdf")
@@ -959,7 +959,7 @@ EOM
959
959
  end
960
960
 
961
961
  def test_assert_not_match_fail_match
962
- check_fail("</string/> expected to not match\n" +
962
+ check_fail("</string/> was expected to not match\n" +
963
963
  "<\"string\">.") do
964
964
  assert_not_match(/string/, "string")
965
965
  end
@@ -967,7 +967,7 @@ EOM
967
967
 
968
968
  def test_assert_not_match_fail_match_with_message
969
969
  check_fail("message.\n" +
970
- "</string/> expected to not match\n" +
970
+ "</string/> was expected to not match\n" +
971
971
  "<\"string\">.") do
972
972
  assert_not_match(/string/, "string", "message")
973
973
  end
@@ -976,13 +976,13 @@ EOM
976
976
  def test_assert_no_match
977
977
  check_nothing_fails{assert_no_match(/sling/, "string")}
978
978
  check_nothing_fails{assert_no_match(/sling/, "string", "message")}
979
- check_fail(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> expected to be instance_of?\n<Regexp> but was\n<String>.}) do
979
+ check_fail(%Q{The first argument to assert_no_match should be a Regexp.\n<"asdf"> was expected to be instance_of?\n<Regexp> but was\n<String>.}) do
980
980
  assert_no_match("asdf", "asdf")
981
981
  end
982
- check_fail(%Q{</string/> expected to not match\n<"string">.}) do
982
+ check_fail(%Q{</string/> was expected to not match\n<"string">.}) do
983
983
  assert_no_match(/string/, "string")
984
984
  end
985
- check_fail(%Q{message.\n</string/> expected to not match\n<"string">.}) do
985
+ check_fail(%Q{message.\n</string/> was expected to not match\n<"string">.}) do
986
986
  assert_no_match(/string/, "string", "message")
987
987
  end
988
988
  end
@@ -996,7 +996,7 @@ EOM
996
996
 
997
997
  tag = :thing2
998
998
  check_fail("message.\n" +
999
- "<:thing> expected to be thrown but\n" +
999
+ "<:thing> was expected to be thrown but\n" +
1000
1000
  "<#{inspect_tag(tag)}> was thrown.") do
1001
1001
  assert_throw(:thing, "message") do
1002
1002
  throw :thing2
@@ -1034,7 +1034,7 @@ EOM
1034
1034
  check_fail(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
1035
1035
  assert_operator("thing", 0.15, "thing")
1036
1036
  end
1037
- check_fail(%Q{message.\n<"thing1"> expected to be\n==\n<"thing2">.}) {
1037
+ check_fail(%Q{message.\n<"thing1"> was expected to be\n==\n<"thing2">.}) {
1038
1038
  assert_operator("thing1", :==, "thing2", "message")
1039
1039
  }
1040
1040
  end
@@ -1046,7 +1046,7 @@ EOM
1046
1046
  check_fail(%Q{<42>\ngiven as the operator for #assert_not_operator must be a Symbol or #respond_to?(:to_str).}) do
1047
1047
  assert_not_operator("thing", 42, "message")
1048
1048
  end
1049
- check_fail(%Q{message.\n<0> expected to not be\n==\n<0.0>.}) {
1049
+ check_fail(%Q{message.\n<0> was expected to not be\n==\n<0.0>.}) {
1050
1050
  assert_not_operator(0, :==, 0.0, "message")
1051
1051
  }
1052
1052
  end
@@ -1111,7 +1111,7 @@ EOM
1111
1111
  inspected_object = AssertionMessage.convert(object)
1112
1112
  expected_message = <<-EOM
1113
1113
  message.
1114
- <#{inspected_object}> expected to respond to
1114
+ <#{inspected_object}> was expected to respond to
1115
1115
  <return_argument(*[false, "bogus"])> with a true value but was
1116
1116
  <false>.
1117
1117
  EOM
@@ -1210,7 +1210,7 @@ EOM
1210
1210
 
1211
1211
  expected_message = <<-EOM
1212
1212
  <15> < <10> should be true
1213
- <15> expected less than
1213
+ <15> was expected to be less than
1214
1214
  <10>.
1215
1215
  EOM
1216
1216
  check_fail(expected_message.chomp) do
@@ -1219,7 +1219,7 @@ EOM
1219
1219
 
1220
1220
  expected_message = <<-EOM
1221
1221
  <15> <= <10> should be true
1222
- <15> expected less than or equal to
1222
+ <15> was expected to be less than or equal to
1223
1223
  <10>.
1224
1224
  EOM
1225
1225
  check_fail(expected_message.chomp) do
@@ -1228,7 +1228,7 @@ EOM
1228
1228
 
1229
1229
  expected_message = <<-EOM
1230
1230
  <10> > <15> should be true
1231
- <10> expected greater than
1231
+ <10> was expected to be greater than
1232
1232
  <15>.
1233
1233
  EOM
1234
1234
  check_fail(expected_message.chomp) do
@@ -1237,7 +1237,7 @@ EOM
1237
1237
 
1238
1238
  expected_message = <<-EOM
1239
1239
  <10> >= <15> should be true
1240
- <10> expected greater than or equal to
1240
+ <10> was expected to be greater than or equal to
1241
1241
  <15>.
1242
1242
  EOM
1243
1243
  check_fail(expected_message.chomp) do
@@ -1288,7 +1288,7 @@ EOM
1288
1288
  end
1289
1289
 
1290
1290
  expected_message = <<-EOM
1291
- <"Expected message"> exception message expected but none was thrown.
1291
+ <"Expected message"> exception message was expected but none was thrown.
1292
1292
  EOM
1293
1293
  check_fail(expected_message.chomp) do
1294
1294
  assert_raise_message("Expected message") do
@@ -1414,7 +1414,7 @@ EOM
1414
1414
  end
1415
1415
 
1416
1416
  nonexistent_file = __FILE__ + ".nonexistent"
1417
- check_fail("<#{nonexistent_file.inspect}> expected to exist") do
1417
+ check_fail("<#{nonexistent_file.inspect}> was expected to exist") do
1418
1418
  assert_path_exist(nonexistent_file)
1419
1419
  end
1420
1420
  end
@@ -1425,7 +1425,7 @@ EOM
1425
1425
  assert_path_not_exist(nonexistent_file)
1426
1426
  end
1427
1427
 
1428
- check_fail("<#{__FILE__.inspect}> expected to not exist") do
1428
+ check_fail("<#{__FILE__.inspect}> was expected to not exist") do
1429
1429
  assert_path_not_exist(__FILE__)
1430
1430
  end
1431
1431
  end
@@ -1521,15 +1521,18 @@ EOM
1521
1521
  class TestBlock < self
1522
1522
  def test_with_message
1523
1523
  if defined?(PowerAssert)
1524
- system_message = <<-MESSAGE
1525
- 1 == 2
1524
+ system_message = <<-MESSAGE.chomp
1525
+ 1.to_s == "2"
1526
+ | |
1527
+ | false
1528
+ "1"
1526
1529
  MESSAGE
1527
1530
  else
1528
1531
  system_message = "<false> is not true."
1529
1532
  end
1530
1533
  check_fail("user message.\n#{system_message}") do
1531
1534
  assert("user message") do
1532
- 1 == 2
1535
+ 1.to_s == "2"
1533
1536
  end
1534
1537
  end
1535
1538
  end
@@ -1635,7 +1638,7 @@ MESSAGE
1635
1638
 
1636
1639
  def test_fail_with_message
1637
1640
  check_fail("message.\n" +
1638
- "<0.5> -/+ <0.05> expected to include\n" +
1641
+ "<0.5> -/+ <0.05> was expected to include\n" +
1639
1642
  "<0.4>.\n" +
1640
1643
  "\n" +
1641
1644
  "Relation:\n" +
@@ -1657,13 +1660,13 @@ MESSAGE
1657
1660
 
1658
1661
  def test_fail_because_negaitve_delta
1659
1662
  check_fail("The delta should not be negative.\n" +
1660
- "<-0.1> expected to be\n>=\n<0.0>.") do
1663
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1661
1664
  assert_in_delta(0.5, 0.4, -0.1, "message")
1662
1665
  end
1663
1666
  end
1664
1667
 
1665
1668
  def test_fail_without_delta
1666
- check_fail("<1.402> -/+ <0.001> expected to include\n" +
1669
+ check_fail("<1.402> -/+ <0.001> was expected to include\n" +
1667
1670
  "<1.404>.\n" +
1668
1671
  "\n" +
1669
1672
  "Relation:\n" +
@@ -1715,7 +1718,7 @@ MESSAGE
1715
1718
  end
1716
1719
 
1717
1720
  def test_fail
1718
- check_fail("<1.4> -/+ <0.11> expected to not include\n" +
1721
+ check_fail("<1.4> -/+ <0.11> was expected to not include\n" +
1719
1722
  "<1.5>.\n" +
1720
1723
  "\n" +
1721
1724
  "Relation:\n" +
@@ -1729,7 +1732,7 @@ MESSAGE
1729
1732
  end
1730
1733
 
1731
1734
  def test_fail_without_delta
1732
- check_fail("<1.402> -/+ <0.001> expected to not include\n" +
1735
+ check_fail("<1.402> -/+ <0.001> was expected to not include\n" +
1733
1736
  "<1.4021>.\n" +
1734
1737
  "\n" +
1735
1738
  "Relation:\n" +
@@ -1744,7 +1747,7 @@ MESSAGE
1744
1747
 
1745
1748
  def test_fail_with_message
1746
1749
  check_fail("message.\n" +
1747
- "<0.5> -/+ <0.11> expected to not include\n" +
1750
+ "<0.5> -/+ <0.11> was expected to not include\n" +
1748
1751
  "<0.4>.\n" +
1749
1752
  "\n" +
1750
1753
  "Relation:\n" +
@@ -1770,7 +1773,7 @@ MESSAGE
1770
1773
 
1771
1774
  def test_fail_because_negaitve_delta
1772
1775
  check_fail("The delta should not be negative.\n" +
1773
- "<-0.11> expected to be\n>=\n<0.0>.") do
1776
+ "<-0.11> was expected to be\n>=\n<0.0>.") do
1774
1777
  assert_not_in_delta(0.5, 0.4, -0.11, "message")
1775
1778
  end
1776
1779
  end
@@ -1828,7 +1831,7 @@ MESSAGE
1828
1831
  def test_fail_with_message
1829
1832
  check_fail("message.\n" +
1830
1833
  "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1831
- "expected to include\n" +
1834
+ "was expected to include\n" +
1832
1835
  "<8999>.\n" +
1833
1836
  "\n" +
1834
1837
  "Relation:\n" +
@@ -1854,14 +1857,14 @@ MESSAGE
1854
1857
 
1855
1858
  def test_fail_because_negaitve_epsilon
1856
1859
  check_fail("The epsilon should not be negative.\n" +
1857
- "<-0.1> expected to be\n>=\n<0.0>.") do
1860
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1858
1861
  assert_in_epsilon(10000, 9000, -0.1, "message")
1859
1862
  end
1860
1863
  end
1861
1864
 
1862
1865
  def test_fail_without_epsilon
1863
1866
  check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1864
- "expected to include\n" +
1867
+ "was expected to include\n" +
1865
1868
  "<10011>.\n" +
1866
1869
  "\n" +
1867
1870
  "Relation:\n" +
@@ -1914,7 +1917,7 @@ MESSAGE
1914
1917
 
1915
1918
  def test_fail
1916
1919
  check_fail("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1917
- "expected to not include\n" +
1920
+ "was expected to not include\n" +
1918
1921
  "<9000>.\n" +
1919
1922
  "\n" +
1920
1923
  "Relation:\n" +
@@ -1929,7 +1932,7 @@ MESSAGE
1929
1932
 
1930
1933
  def test_fail_without_epsilon
1931
1934
  check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
1932
- "expected to not include\n" +
1935
+ "was expected to not include\n" +
1933
1936
  "<9990>.\n" +
1934
1937
  "\n" +
1935
1938
  "Relation:\n" +
@@ -1945,7 +1948,7 @@ MESSAGE
1945
1948
  def test_fail_with_message
1946
1949
  check_fail("message.\n" +
1947
1950
  "<10000> -/+ (<10000> * <0.1>)[1000.0] " +
1948
- "expected to not include\n" +
1951
+ "was expected to not include\n" +
1949
1952
  "<9000>.\n" +
1950
1953
  "\n" +
1951
1954
  "Relation:\n" +
@@ -1971,7 +1974,7 @@ MESSAGE
1971
1974
 
1972
1975
  def test_fail_because_negaitve_epsilon
1973
1976
  check_fail("The epsilon should not be negative.\n" +
1974
- "<-0.1> expected to be\n>=\n<0.0>.") do
1977
+ "<-0.1> was expected to be\n>=\n<0.0>.") do
1975
1978
  assert_not_in_epsilon(10000, 9000, -0.1, "message")
1976
1979
  end
1977
1980
  end
@@ -1993,7 +1996,7 @@ MESSAGE
1993
1996
  end
1994
1997
 
1995
1998
  def test_fail
1996
- check_fail("<[1, 2, 3]> expected to include\n" +
1999
+ check_fail("<[1, 2, 3]> was expected to include\n" +
1997
2000
  "<4>.") do
1998
2001
  assert_include([1, 2, 3], 4)
1999
2002
  end
@@ -2001,7 +2004,7 @@ MESSAGE
2001
2004
 
2002
2005
  def test_fail_with_message
2003
2006
  check_fail("message.\n" +
2004
- "<[1, 2, 3]> expected to include\n" +
2007
+ "<[1, 2, 3]> was expected to include\n" +
2005
2008
  "<4>.") do
2006
2009
  assert_include([1, 2, 3], 4, "message")
2007
2010
  end
@@ -2034,7 +2037,7 @@ MESSAGE
2034
2037
  end
2035
2038
 
2036
2039
  def test_fail
2037
- check_fail("<[1, 2, 3]> expected to not include\n" +
2040
+ check_fail("<[1, 2, 3]> was expected to not include\n" +
2038
2041
  "<2>.") do
2039
2042
  assert_not_include([1, 2, 3], 2)
2040
2043
  end
@@ -2042,7 +2045,7 @@ MESSAGE
2042
2045
 
2043
2046
  def test_fail_with_message
2044
2047
  check_fail("message.\n" +
2045
- "<[1, 2, 3]> expected to not include\n" +
2048
+ "<[1, 2, 3]> was expected to not include\n" +
2046
2049
  "<2>.") do
2047
2050
  assert_not_include([1, 2, 3], 2, "message")
2048
2051
  end
@@ -2075,14 +2078,14 @@ MESSAGE
2075
2078
  end
2076
2079
 
2077
2080
  def test_fail
2078
- check_fail("<[1]> expected to be empty.") do
2081
+ check_fail("<[1]> was expected to be empty.") do
2079
2082
  assert_empty([1])
2080
2083
  end
2081
2084
  end
2082
2085
 
2083
2086
  def test_fail_with_message
2084
2087
  check_fail("message.\n" +
2085
- "<[1]> expected to be empty.") do
2088
+ "<[1]> was expected to be empty.") do
2086
2089
  assert_empty([1], "message")
2087
2090
  end
2088
2091
  end
@@ -2114,14 +2117,14 @@ MESSAGE
2114
2117
  end
2115
2118
 
2116
2119
  def test_fail
2117
- check_fail("<[]> expected to not be empty.") do
2120
+ check_fail("<[]> was expected to not be empty.") do
2118
2121
  assert_not_empty([])
2119
2122
  end
2120
2123
  end
2121
2124
 
2122
2125
  def test_fail_with_message
2123
2126
  check_fail("message.\n" +
2124
- "<[]> expected to not be empty.") do
2127
+ "<[]> was expected to not be empty.") do
2125
2128
  assert_not_empty([], "message")
2126
2129
  end
2127
2130
  end
@@ -2149,7 +2152,7 @@ MESSAGE
2149
2152
  def test_fail
2150
2153
  expected_message = <<-EOM
2151
2154
  message.
2152
- <[1, 2]> expected to respond to
2155
+ <[1, 2]> was expected to respond to
2153
2156
  <member?(*[2])> with not a true value but was
2154
2157
  <true>.
2155
2158
  EOM