test-unit 3.2.0 → 3.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/COPYING +4 -1
- data/README.md +11 -11
- data/Rakefile +10 -1
- data/doc/text/getting-started.md +246 -0
- data/doc/text/news.md +372 -1
- data/lib/test/unit.rb +171 -157
- data/lib/test/unit/assertions.rb +187 -149
- data/lib/test/unit/attribute.rb +71 -2
- data/lib/test/unit/autorunner.rb +65 -32
- data/lib/test/unit/code-snippet-fetcher.rb +7 -7
- data/lib/test/unit/collector/load.rb +8 -13
- data/lib/test/unit/data-sets.rb +116 -0
- data/lib/test/unit/data.rb +121 -12
- data/lib/test/unit/diff.rb +11 -11
- data/lib/test/unit/fixture.rb +3 -0
- data/lib/test/unit/notification.rb +9 -7
- data/lib/test/unit/omission.rb +34 -31
- data/lib/test/unit/pending.rb +12 -11
- data/lib/test/unit/priority.rb +7 -3
- data/lib/test/unit/runner/console.rb +25 -0
- data/lib/test/unit/test-suite-creator.rb +22 -8
- data/lib/test/unit/testcase.rb +270 -182
- data/lib/test/unit/ui/console/testrunner.rb +90 -35
- data/lib/test/unit/ui/emacs/testrunner.rb +5 -5
- data/lib/test/unit/util/observable.rb +2 -2
- data/lib/test/unit/util/output.rb +5 -4
- data/lib/test/unit/util/procwrapper.rb +4 -4
- data/lib/test/unit/version.rb +1 -1
- data/test/collector/test-descendant.rb +4 -0
- data/test/collector/test-load.rb +35 -2
- data/test/collector/test_dir.rb +5 -4
- data/test/collector/test_objectspace.rb +7 -5
- data/test/test-assertions.rb +128 -101
- data/test/test-code-snippet.rb +42 -0
- data/test/test-data.rb +195 -79
- data/test/test-priority.rb +19 -8
- data/test/test-test-case.rb +111 -3
- data/test/test-test-suite.rb +1 -0
- data/test/testunit-test-util.rb +2 -0
- metadata +38 -37
data/test/test-assertions.rb
CHANGED
@@ -32,6 +32,7 @@ module Test
|
|
32
32
|
return_value = yield
|
33
33
|
failed = false
|
34
34
|
rescue AssertionFailedError => error
|
35
|
+
return_value = error
|
35
36
|
actual_message = error.message
|
36
37
|
end
|
37
38
|
@catch_assertions = false
|
@@ -288,21 +289,26 @@ EOM
|
|
288
289
|
end
|
289
290
|
|
290
291
|
def test_same_inspected_objects
|
291
|
-
|
292
|
-
|
292
|
+
same_inspected_class = Class.new do
|
293
|
+
def inspect
|
294
|
+
"inspected"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
object1 = same_inspected_class.new
|
298
|
+
object2 = same_inspected_class.new
|
293
299
|
message = <<-EOM.chomp
|
294
|
-
|
295
|
-
|
300
|
+
<inspected> expected but was
|
301
|
+
<inspected>.
|
296
302
|
EOM
|
297
303
|
check_fail(message) do
|
298
|
-
assert_equal(
|
304
|
+
assert_equal(object1, object2)
|
299
305
|
end
|
300
306
|
end
|
301
307
|
|
302
308
|
def test_multi_lines_result
|
303
309
|
message = <<-EOM.chomp
|
304
|
-
<#{"a\nb"
|
305
|
-
<#{"x"
|
310
|
+
<#{AssertionMessage.convert("a\nb")}> expected but was
|
311
|
+
<#{AssertionMessage.convert("x")}>.
|
306
312
|
|
307
313
|
diff:
|
308
314
|
+ x
|
@@ -316,8 +322,8 @@ EOM
|
|
316
322
|
|
317
323
|
def test_large_string
|
318
324
|
message = <<-EOM.chomp
|
319
|
-
<#{("a\n" + "x" * 997)
|
320
|
-
<#{"x"
|
325
|
+
<#{AssertionMessage.convert("a\n" + "x" * 997)}> expected but was
|
326
|
+
<#{AssertionMessage.convert("x")}>.
|
321
327
|
|
322
328
|
diff:
|
323
329
|
+ x
|
@@ -335,8 +341,8 @@ EOM
|
|
335
341
|
end
|
336
342
|
|
337
343
|
message = <<-EOM.chomp
|
338
|
-
<#{("a\n" + "x" * 998)
|
339
|
-
<#{"x"
|
344
|
+
<#{AssertionMessage.convert("a\n" + "x" * 998)}> expected but was
|
345
|
+
<#{AssertionMessage.convert("x")}>.
|
340
346
|
EOM
|
341
347
|
check_fail(message) do
|
342
348
|
assert_equal("a\n" + "x" * 998, "x")
|
@@ -349,8 +355,8 @@ EOM
|
|
349
355
|
ENV[key] = "100"
|
350
356
|
begin
|
351
357
|
message = <<-EOM.chomp
|
352
|
-
<#{("a\n" + "x" * 97)
|
353
|
-
<#{"x"
|
358
|
+
<#{AssertionMessage.convert("a\n" + "x" * 97)}> expected but was
|
359
|
+
<#{AssertionMessage.convert("x")}>.
|
354
360
|
|
355
361
|
diff:
|
356
362
|
+ x
|
@@ -368,8 +374,8 @@ EOM
|
|
368
374
|
end
|
369
375
|
|
370
376
|
message = <<-EOM.chomp
|
371
|
-
<#{("a\n" + "x" * 98)
|
372
|
-
<#{"x"
|
377
|
+
<#{AssertionMessage.convert("a\n" + "x" * 98)}> expected but was
|
378
|
+
<#{AssertionMessage.convert("x")}>.
|
373
379
|
EOM
|
374
380
|
check_fail(message) do
|
375
381
|
assert_equal("a\n" + "x" * 98, "x")
|
@@ -495,7 +501,7 @@ EOM
|
|
495
501
|
end
|
496
502
|
|
497
503
|
def test_assert_raise_fail
|
498
|
-
check_fail("<RuntimeError> exception expected but none was thrown.") do
|
504
|
+
check_fail("<RuntimeError> exception was expected but none was thrown.") do
|
499
505
|
assert_raise(RuntimeError) do
|
500
506
|
1 + 1
|
501
507
|
end
|
@@ -513,8 +519,7 @@ EOM
|
|
513
519
|
end
|
514
520
|
|
515
521
|
message = <<-EOM
|
516
|
-
|
517
|
-
<false> is not true.
|
522
|
+
<Object> must be a subclass of Exception, an object of Exception subclasses or a Module.
|
518
523
|
EOM
|
519
524
|
check_fail(message.chomp) do
|
520
525
|
assert_nothing_raised(Object) do
|
@@ -557,7 +562,7 @@ EOM
|
|
557
562
|
end
|
558
563
|
|
559
564
|
check_fail("<[ArgumentError, TypeError, Math, Comparable]> exception " +
|
560
|
-
"expected but none was thrown.") do
|
565
|
+
"was expected but none was thrown.") do
|
561
566
|
assert_raise(*rescues) do
|
562
567
|
1 + 1
|
563
568
|
end
|
@@ -639,6 +644,21 @@ EOM
|
|
639
644
|
end
|
640
645
|
end
|
641
646
|
|
647
|
+
def test_assert_raise_jruby
|
648
|
+
omit("For JRuby") unless Object.const_defined?(:Java)
|
649
|
+
|
650
|
+
exception = Java::JavaLang::StringIndexOutOfBoundsException
|
651
|
+
|
652
|
+
return_value = nil
|
653
|
+
check_nothing_fails(true) do
|
654
|
+
return_value = assert_raise(exception) do
|
655
|
+
Java::JavaLang::String.new("abc").char_at(4)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
check(return_value.instance_of?(exception),
|
659
|
+
"Should have returned #{exception} but was #{return_value.class}")
|
660
|
+
end
|
661
|
+
|
642
662
|
def test_assert_instance_of
|
643
663
|
check_nothing_fails {
|
644
664
|
assert_instance_of(String, "string")
|
@@ -649,21 +669,21 @@ EOM
|
|
649
669
|
check_nothing_fails {
|
650
670
|
assert_instance_of(String, "string", "successful assert_instance_of")
|
651
671
|
}
|
652
|
-
check_fail(%Q{<"string"> expected to be instance_of?\n<Hash> but was\n<String>.}) {
|
672
|
+
check_fail(%Q{<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
|
653
673
|
assert_instance_of(Hash, "string")
|
654
674
|
}
|
655
|
-
check_fail(%Q{failed assert_instance_of.\n<"string"> expected to be instance_of?\n<Hash> but was\n<String>.}) {
|
675
|
+
check_fail(%Q{failed assert_instance_of.\n<"string"> was expected to be instance_of?\n<Hash> but was\n<String>.}) {
|
656
676
|
assert_instance_of(Hash, "string", "failed assert_instance_of")
|
657
677
|
}
|
658
678
|
|
659
679
|
check_nothing_fails do
|
660
|
-
assert_instance_of([
|
680
|
+
assert_instance_of([Class, NilClass], Array)
|
661
681
|
end
|
662
|
-
check_fail(%Q{<"string"> expected to be instance_of?\n[<
|
663
|
-
assert_instance_of([
|
682
|
+
check_fail(%Q{<"string"> was expected to be instance_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
|
683
|
+
assert_instance_of([Class, NilClass], "string")
|
664
684
|
end
|
665
|
-
check_fail(%Q{<
|
666
|
-
assert_instance_of([
|
685
|
+
check_fail(%Q{<Array> was expected to be instance_of?\n[<Module>, <NilClass>] but was\n<Class>.}) do
|
686
|
+
assert_instance_of([Module, NilClass], Array)
|
667
687
|
end
|
668
688
|
end
|
669
689
|
|
@@ -674,20 +694,20 @@ EOM
|
|
674
694
|
check_nothing_fails {
|
675
695
|
assert_not_instance_of(NilClass, "string", "successful assert_instance_of")
|
676
696
|
}
|
677
|
-
check_fail(%Q{<"string"> expected to not be instance_of?\n<String> but was.}) {
|
697
|
+
check_fail(%Q{<"string"> was expected to not be instance_of?\n<String> but was.}) {
|
678
698
|
assert_not_instance_of(String, "string")
|
679
699
|
}
|
680
|
-
check_fail(%Q{failed assert.\n<"string"> expected to not be instance_of?\n<String> but was.}) {
|
700
|
+
check_fail(%Q{failed assert.\n<"string"> was expected to not be instance_of?\n<String> but was.}) {
|
681
701
|
assert_not_instance_of(String, "string", "failed assert")
|
682
702
|
}
|
683
703
|
|
684
704
|
check_nothing_fails do
|
685
|
-
assert_not_instance_of([
|
705
|
+
assert_not_instance_of([Module, NilClass], Array)
|
686
706
|
end
|
687
|
-
check_fail(%Q{<
|
688
|
-
assert_not_instance_of([
|
707
|
+
check_fail(%Q{<Array> was expected to not be instance_of?\n[<Class>, <NilClass>] but was.}) do
|
708
|
+
assert_not_instance_of([Class, NilClass], Array)
|
689
709
|
end
|
690
|
-
check_fail(%Q{<"str"> expected to not be instance_of?\n[<Numeric>, <String>] but was.}) do
|
710
|
+
check_fail(%Q{<"str"> was expected to not be instance_of?\n[<Numeric>, <String>] but was.}) do
|
691
711
|
assert_not_instance_of([Numeric, String], 'str')
|
692
712
|
end
|
693
713
|
end
|
@@ -702,10 +722,10 @@ EOM
|
|
702
722
|
check_nothing_fails {
|
703
723
|
assert_nil(nil, "successful assert_nil")
|
704
724
|
}
|
705
|
-
check_fail(%Q{<"string"> expected to be nil.}) {
|
725
|
+
check_fail(%Q{<"string"> was expected to be nil.}) {
|
706
726
|
assert_nil("string")
|
707
727
|
}
|
708
|
-
check_fail(%Q{failed assert_nil.\n<"string"> expected to be nil.}) {
|
728
|
+
check_fail(%Q{failed assert_nil.\n<"string"> was expected to be nil.}) {
|
709
729
|
assert_nil("string", "failed assert_nil")
|
710
730
|
}
|
711
731
|
end
|
@@ -713,8 +733,8 @@ EOM
|
|
713
733
|
def test_assert_not_nil
|
714
734
|
check_nothing_fails{assert_not_nil(false)}
|
715
735
|
check_nothing_fails{assert_not_nil(false, "message")}
|
716
|
-
check_fail("<nil> expected to not be nil."){assert_not_nil(nil)}
|
717
|
-
check_fail("message.\n<nil> expected to not be nil.") {assert_not_nil(nil, "message")}
|
736
|
+
check_fail("<nil> was expected to not be nil."){assert_not_nil(nil)}
|
737
|
+
check_fail("message.\n<nil> was expected to not be nil.") {assert_not_nil(nil, "message")}
|
718
738
|
end
|
719
739
|
|
720
740
|
def test_assert_kind_of
|
@@ -730,18 +750,18 @@ EOM
|
|
730
750
|
check_nothing_fails {
|
731
751
|
assert_kind_of(Comparable, 1)
|
732
752
|
}
|
733
|
-
check_fail(%Q{<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
|
753
|
+
check_fail(%Q{<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
|
734
754
|
assert_kind_of(Class, "string")
|
735
755
|
}
|
736
|
-
check_fail(%Q{failed assert_kind_of.\n<"string"> expected to be kind_of?\n<Class> but was\n<String>.}) {
|
756
|
+
check_fail(%Q{failed assert_kind_of.\n<"string"> was expected to be kind_of?\n<Class> but was\n<String>.}) {
|
737
757
|
assert_kind_of(Class, "string", "failed assert_kind_of")
|
738
758
|
}
|
739
759
|
|
740
760
|
check_nothing_fails do
|
741
|
-
assert_kind_of([
|
761
|
+
assert_kind_of([Class, NilClass], Array)
|
742
762
|
end
|
743
|
-
check_fail(%Q{<"string"> expected to be kind_of?\n[<
|
744
|
-
assert_kind_of([
|
763
|
+
check_fail(%Q{<"string"> was expected to be kind_of?\n[<Class>, <NilClass>] but was\n<String>.}) do
|
764
|
+
assert_kind_of([Class, NilClass], "string")
|
745
765
|
end
|
746
766
|
end
|
747
767
|
|
@@ -755,18 +775,18 @@ EOM
|
|
755
775
|
check_nothing_fails {
|
756
776
|
assert_not_kind_of(Integer, 1.1)
|
757
777
|
}
|
758
|
-
check_fail(%Q{<1> expected to not be kind_of?\n<Integer> but was.}) {
|
778
|
+
check_fail(%Q{<1> was expected to not be kind_of?\n<Integer> but was.}) {
|
759
779
|
assert_not_kind_of(Integer, 1)
|
760
780
|
}
|
761
|
-
check_fail(%Q{failed assert_not_kind_of.\n<"string"> expected to not be kind_of?\n<String> but was.}) {
|
781
|
+
check_fail(%Q{failed assert_not_kind_of.\n<"string"> was expected to not be kind_of?\n<String> but was.}) {
|
762
782
|
assert_not_kind_of(String, "string", "failed assert_not_kind_of")
|
763
783
|
}
|
764
784
|
|
765
785
|
check_nothing_fails do
|
766
786
|
assert_not_kind_of([String, NilClass], 100)
|
767
787
|
end
|
768
|
-
check_fail(%Q{<
|
769
|
-
assert_not_kind_of([
|
788
|
+
check_fail(%Q{<Array> was expected to not be kind_of?\n[<Class>, <NilClass>] but was.}) do
|
789
|
+
assert_not_kind_of([Class, NilClass], Array)
|
770
790
|
end
|
771
791
|
end
|
772
792
|
|
@@ -783,13 +803,13 @@ EOM
|
|
783
803
|
check_nothing_fails {
|
784
804
|
assert_match(/strin./, "string", "successful assert_match")
|
785
805
|
}
|
786
|
-
check_fail(%Q{</slin./> expected to be =~\n<"string">.}) {
|
806
|
+
check_fail(%Q{</slin./> was expected to be =~\n<"string">.}) {
|
787
807
|
assert_match(/slin./, "string")
|
788
808
|
}
|
789
|
-
check_fail(%Q{</strin\\./> expected to be =~\n<"string">.}) {
|
809
|
+
check_fail(%Q{</strin\\./> was expected to be =~\n<"string">.}) {
|
790
810
|
assert_match("strin.", "string")
|
791
811
|
}
|
792
|
-
check_fail(%Q{failed assert_match.\n</slin./> expected to be =~\n<"string">.}) {
|
812
|
+
check_fail(%Q{failed assert_match.\n</slin./> was expected to be =~\n<"string">.}) {
|
793
813
|
assert_match(/slin./, "string", "failed assert_match")
|
794
814
|
}
|
795
815
|
end
|
@@ -805,11 +825,11 @@ EOM
|
|
805
825
|
check_nothing_fails {
|
806
826
|
assert_same(thing, thing, "successful assert_same")
|
807
827
|
}
|
808
|
-
thing2 =
|
809
|
-
check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
|
828
|
+
thing2 = thing.dup
|
829
|
+
check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
|
810
830
|
assert_same(thing, thing2)
|
811
831
|
}
|
812
|
-
check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
|
832
|
+
check_fail(%Q{failed assert_same.\n<"thing">\nwith id <#{thing.__id__}> was expected to be equal? to\n<"thing">\nwith id <#{thing2.__id__}>.}) {
|
813
833
|
assert_same(thing, thing2, "failed assert_same")
|
814
834
|
}
|
815
835
|
end
|
@@ -838,7 +858,10 @@ EOM
|
|
838
858
|
rescue ZeroDivisionError
|
839
859
|
end
|
840
860
|
}
|
841
|
-
|
861
|
+
expected_message =
|
862
|
+
"<Object> must be a subclass of Exception, " +
|
863
|
+
"an object of Exception subclasses or a Module."
|
864
|
+
check_fail(expected_message) {
|
842
865
|
assert_nothing_raised(Object) {
|
843
866
|
1 + 1
|
844
867
|
}
|
@@ -889,17 +912,17 @@ EOM
|
|
889
912
|
|
890
913
|
def test_assert_not_same
|
891
914
|
thing = "thing"
|
892
|
-
thing2 =
|
915
|
+
thing2 = thing.dup
|
893
916
|
check_nothing_fails {
|
894
917
|
assert_not_same(thing, thing2)
|
895
918
|
}
|
896
919
|
check_nothing_fails {
|
897
920
|
assert_not_same(thing, thing2, "message")
|
898
921
|
}
|
899
|
-
check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
|
922
|
+
check_fail(%Q{<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
|
900
923
|
assert_not_same(thing, thing)
|
901
924
|
}
|
902
|
-
check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
|
925
|
+
check_fail(%Q{message.\n<"thing">\nwith id <#{thing.__id__}> was expected to not be equal? to\n<"thing">\nwith id <#{thing.__id__}>.}) {
|
903
926
|
assert_not_same(thing, thing, "message")
|
904
927
|
}
|
905
928
|
end
|
@@ -911,10 +934,10 @@ EOM
|
|
911
934
|
check_nothing_fails {
|
912
935
|
assert_not_equal("string1", "string2", "message")
|
913
936
|
}
|
914
|
-
check_fail(%Q{<"string"> expected to be != to\n<"string">.}) {
|
937
|
+
check_fail(%Q{<"string"> was expected to be != to\n<"string">.}) {
|
915
938
|
assert_not_equal("string", "string")
|
916
939
|
}
|
917
|
-
check_fail(%Q{message.\n<"string"> expected to be != to\n<"string">.}) {
|
940
|
+
check_fail(%Q{message.\n<"string"> was expected to be != to\n<"string">.}) {
|
918
941
|
assert_not_equal("string", "string", "message")
|
919
942
|
}
|
920
943
|
end
|
@@ -934,7 +957,7 @@ EOM
|
|
934
957
|
def test_assert_not_match_fail_not_regexp
|
935
958
|
check_fail("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
|
936
959
|
"should be a Regexp.\n" +
|
937
|
-
"<\"asdf\"> expected to be instance_of?\n" +
|
960
|
+
"<\"asdf\"> was expected to be instance_of?\n" +
|
938
961
|
"<Regexp> but was\n" +
|
939
962
|
"<String>.") do
|
940
963
|
assert_not_match("asdf", "asdf")
|
@@ -942,7 +965,7 @@ EOM
|
|
942
965
|
end
|
943
966
|
|
944
967
|
def test_assert_not_match_fail_match
|
945
|
-
check_fail("</string/> expected to not match\n" +
|
968
|
+
check_fail("</string/> was expected to not match\n" +
|
946
969
|
"<\"string\">.") do
|
947
970
|
assert_not_match(/string/, "string")
|
948
971
|
end
|
@@ -950,7 +973,7 @@ EOM
|
|
950
973
|
|
951
974
|
def test_assert_not_match_fail_match_with_message
|
952
975
|
check_fail("message.\n" +
|
953
|
-
"</string/> expected to not match\n" +
|
976
|
+
"</string/> was expected to not match\n" +
|
954
977
|
"<\"string\">.") do
|
955
978
|
assert_not_match(/string/, "string", "message")
|
956
979
|
end
|
@@ -959,13 +982,13 @@ EOM
|
|
959
982
|
def test_assert_no_match
|
960
983
|
check_nothing_fails{assert_no_match(/sling/, "string")}
|
961
984
|
check_nothing_fails{assert_no_match(/sling/, "string", "message")}
|
962
|
-
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
|
985
|
+
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
|
963
986
|
assert_no_match("asdf", "asdf")
|
964
987
|
end
|
965
|
-
check_fail(%Q{</string/> expected to not match\n<"string">.}) do
|
988
|
+
check_fail(%Q{</string/> was expected to not match\n<"string">.}) do
|
966
989
|
assert_no_match(/string/, "string")
|
967
990
|
end
|
968
|
-
check_fail(%Q{message.\n</string/> expected to not match\n<"string">.}) do
|
991
|
+
check_fail(%Q{message.\n</string/> was expected to not match\n<"string">.}) do
|
969
992
|
assert_no_match(/string/, "string", "message")
|
970
993
|
end
|
971
994
|
end
|
@@ -979,7 +1002,7 @@ EOM
|
|
979
1002
|
|
980
1003
|
tag = :thing2
|
981
1004
|
check_fail("message.\n" +
|
982
|
-
"<:thing> expected to be thrown but\n" +
|
1005
|
+
"<:thing> was expected to be thrown but\n" +
|
983
1006
|
"<#{inspect_tag(tag)}> was thrown.") do
|
984
1007
|
assert_throw(:thing, "message") do
|
985
1008
|
throw :thing2
|
@@ -1017,7 +1040,7 @@ EOM
|
|
1017
1040
|
check_fail(%Q{<0.15>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to?(:to_str).}) do
|
1018
1041
|
assert_operator("thing", 0.15, "thing")
|
1019
1042
|
end
|
1020
|
-
check_fail(%Q{message.\n<"thing1"> expected to be\n==\n<"thing2">.}) {
|
1043
|
+
check_fail(%Q{message.\n<"thing1"> was expected to be\n==\n<"thing2">.}) {
|
1021
1044
|
assert_operator("thing1", :==, "thing2", "message")
|
1022
1045
|
}
|
1023
1046
|
end
|
@@ -1029,7 +1052,7 @@ EOM
|
|
1029
1052
|
check_fail(%Q{<42>\ngiven as the operator for #assert_not_operator must be a Symbol or #respond_to?(:to_str).}) do
|
1030
1053
|
assert_not_operator("thing", 42, "message")
|
1031
1054
|
end
|
1032
|
-
check_fail(%Q{message.\n<0> expected to not be\n==\n<0.0>.}) {
|
1055
|
+
check_fail(%Q{message.\n<0> was expected to not be\n==\n<0.0>.}) {
|
1033
1056
|
assert_not_operator(0, :==, 0.0, "message")
|
1034
1057
|
}
|
1035
1058
|
end
|
@@ -1094,7 +1117,7 @@ EOM
|
|
1094
1117
|
inspected_object = AssertionMessage.convert(object)
|
1095
1118
|
expected_message = <<-EOM
|
1096
1119
|
message.
|
1097
|
-
<#{inspected_object}> expected to respond to
|
1120
|
+
<#{inspected_object}> was expected to respond to
|
1098
1121
|
<return_argument(*[false, "bogus"])> with a true value but was
|
1099
1122
|
<false>.
|
1100
1123
|
EOM
|
@@ -1151,9 +1174,10 @@ EOM
|
|
1151
1174
|
assert_true(1)
|
1152
1175
|
end
|
1153
1176
|
|
1154
|
-
check_fail("message.\n<true> expected but was\n<nil>") do
|
1177
|
+
exception = check_fail("message.\n<true> expected but was\n<nil>") do
|
1155
1178
|
assert_true(nil, "message")
|
1156
1179
|
end
|
1180
|
+
assert_equal("message", exception.user_message)
|
1157
1181
|
end
|
1158
1182
|
|
1159
1183
|
def test_assert_false
|
@@ -1193,7 +1217,7 @@ EOM
|
|
1193
1217
|
|
1194
1218
|
expected_message = <<-EOM
|
1195
1219
|
<15> < <10> should be true
|
1196
|
-
<15> expected less than
|
1220
|
+
<15> was expected to be less than
|
1197
1221
|
<10>.
|
1198
1222
|
EOM
|
1199
1223
|
check_fail(expected_message.chomp) do
|
@@ -1202,7 +1226,7 @@ EOM
|
|
1202
1226
|
|
1203
1227
|
expected_message = <<-EOM
|
1204
1228
|
<15> <= <10> should be true
|
1205
|
-
<15> expected less than or equal to
|
1229
|
+
<15> was expected to be less than or equal to
|
1206
1230
|
<10>.
|
1207
1231
|
EOM
|
1208
1232
|
check_fail(expected_message.chomp) do
|
@@ -1211,7 +1235,7 @@ EOM
|
|
1211
1235
|
|
1212
1236
|
expected_message = <<-EOM
|
1213
1237
|
<10> > <15> should be true
|
1214
|
-
<10> expected greater than
|
1238
|
+
<10> was expected to be greater than
|
1215
1239
|
<15>.
|
1216
1240
|
EOM
|
1217
1241
|
check_fail(expected_message.chomp) do
|
@@ -1220,7 +1244,7 @@ EOM
|
|
1220
1244
|
|
1221
1245
|
expected_message = <<-EOM
|
1222
1246
|
<10> >= <15> should be true
|
1223
|
-
<10> expected greater than or equal to
|
1247
|
+
<10> was expected to be greater than or equal to
|
1224
1248
|
<15>.
|
1225
1249
|
EOM
|
1226
1250
|
check_fail(expected_message.chomp) do
|
@@ -1271,7 +1295,7 @@ EOM
|
|
1271
1295
|
end
|
1272
1296
|
|
1273
1297
|
expected_message = <<-EOM
|
1274
|
-
<"Expected message"> exception message expected but none was thrown.
|
1298
|
+
<"Expected message"> exception message was expected but none was thrown.
|
1275
1299
|
EOM
|
1276
1300
|
check_fail(expected_message.chomp) do
|
1277
1301
|
assert_raise_message("Expected message") do
|
@@ -1397,7 +1421,7 @@ EOM
|
|
1397
1421
|
end
|
1398
1422
|
|
1399
1423
|
nonexistent_file = __FILE__ + ".nonexistent"
|
1400
|
-
check_fail("<#{nonexistent_file.inspect}> expected to exist") do
|
1424
|
+
check_fail("<#{nonexistent_file.inspect}> was expected to exist") do
|
1401
1425
|
assert_path_exist(nonexistent_file)
|
1402
1426
|
end
|
1403
1427
|
end
|
@@ -1408,7 +1432,7 @@ EOM
|
|
1408
1432
|
assert_path_not_exist(nonexistent_file)
|
1409
1433
|
end
|
1410
1434
|
|
1411
|
-
check_fail("<#{__FILE__.inspect}> expected to not exist") do
|
1435
|
+
check_fail("<#{__FILE__.inspect}> was expected to not exist") do
|
1412
1436
|
assert_path_not_exist(__FILE__)
|
1413
1437
|
end
|
1414
1438
|
end
|
@@ -1504,15 +1528,18 @@ EOM
|
|
1504
1528
|
class TestBlock < self
|
1505
1529
|
def test_with_message
|
1506
1530
|
if defined?(PowerAssert)
|
1507
|
-
system_message = <<-MESSAGE
|
1508
|
-
1 == 2
|
1531
|
+
system_message = <<-MESSAGE.chomp
|
1532
|
+
1.to_s == "2"
|
1533
|
+
| |
|
1534
|
+
| false
|
1535
|
+
"1"
|
1509
1536
|
MESSAGE
|
1510
1537
|
else
|
1511
1538
|
system_message = "<false> is not true."
|
1512
1539
|
end
|
1513
1540
|
check_fail("user message.\n#{system_message}") do
|
1514
1541
|
assert("user message") do
|
1515
|
-
1 == 2
|
1542
|
+
1.to_s == "2"
|
1516
1543
|
end
|
1517
1544
|
end
|
1518
1545
|
end
|
@@ -1618,7 +1645,7 @@ MESSAGE
|
|
1618
1645
|
|
1619
1646
|
def test_fail_with_message
|
1620
1647
|
check_fail("message.\n" +
|
1621
|
-
"<0.5> -/+ <0.05> expected to include\n" +
|
1648
|
+
"<0.5> -/+ <0.05> was expected to include\n" +
|
1622
1649
|
"<0.4>.\n" +
|
1623
1650
|
"\n" +
|
1624
1651
|
"Relation:\n" +
|
@@ -1640,13 +1667,13 @@ MESSAGE
|
|
1640
1667
|
|
1641
1668
|
def test_fail_because_negaitve_delta
|
1642
1669
|
check_fail("The delta should not be negative.\n" +
|
1643
|
-
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1670
|
+
"<-0.1> was expected to be\n>=\n<0.0>.") do
|
1644
1671
|
assert_in_delta(0.5, 0.4, -0.1, "message")
|
1645
1672
|
end
|
1646
1673
|
end
|
1647
1674
|
|
1648
1675
|
def test_fail_without_delta
|
1649
|
-
check_fail("<1.402> -/+ <0.001> expected to include\n" +
|
1676
|
+
check_fail("<1.402> -/+ <0.001> was expected to include\n" +
|
1650
1677
|
"<1.404>.\n" +
|
1651
1678
|
"\n" +
|
1652
1679
|
"Relation:\n" +
|
@@ -1698,7 +1725,7 @@ MESSAGE
|
|
1698
1725
|
end
|
1699
1726
|
|
1700
1727
|
def test_fail
|
1701
|
-
check_fail("<1.4> -/+ <0.11> expected to not include\n" +
|
1728
|
+
check_fail("<1.4> -/+ <0.11> was expected to not include\n" +
|
1702
1729
|
"<1.5>.\n" +
|
1703
1730
|
"\n" +
|
1704
1731
|
"Relation:\n" +
|
@@ -1712,7 +1739,7 @@ MESSAGE
|
|
1712
1739
|
end
|
1713
1740
|
|
1714
1741
|
def test_fail_without_delta
|
1715
|
-
check_fail("<1.402> -/+ <0.001> expected to not include\n" +
|
1742
|
+
check_fail("<1.402> -/+ <0.001> was expected to not include\n" +
|
1716
1743
|
"<1.4021>.\n" +
|
1717
1744
|
"\n" +
|
1718
1745
|
"Relation:\n" +
|
@@ -1727,7 +1754,7 @@ MESSAGE
|
|
1727
1754
|
|
1728
1755
|
def test_fail_with_message
|
1729
1756
|
check_fail("message.\n" +
|
1730
|
-
"<0.5> -/+ <0.11> expected to not include\n" +
|
1757
|
+
"<0.5> -/+ <0.11> was expected to not include\n" +
|
1731
1758
|
"<0.4>.\n" +
|
1732
1759
|
"\n" +
|
1733
1760
|
"Relation:\n" +
|
@@ -1753,7 +1780,7 @@ MESSAGE
|
|
1753
1780
|
|
1754
1781
|
def test_fail_because_negaitve_delta
|
1755
1782
|
check_fail("The delta should not be negative.\n" +
|
1756
|
-
"<-0.11> expected to be\n>=\n<0.0>.") do
|
1783
|
+
"<-0.11> was expected to be\n>=\n<0.0>.") do
|
1757
1784
|
assert_not_in_delta(0.5, 0.4, -0.11, "message")
|
1758
1785
|
end
|
1759
1786
|
end
|
@@ -1811,7 +1838,7 @@ MESSAGE
|
|
1811
1838
|
def test_fail_with_message
|
1812
1839
|
check_fail("message.\n" +
|
1813
1840
|
"<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1814
|
-
"expected to include\n" +
|
1841
|
+
"was expected to include\n" +
|
1815
1842
|
"<8999>.\n" +
|
1816
1843
|
"\n" +
|
1817
1844
|
"Relation:\n" +
|
@@ -1837,14 +1864,14 @@ MESSAGE
|
|
1837
1864
|
|
1838
1865
|
def test_fail_because_negaitve_epsilon
|
1839
1866
|
check_fail("The epsilon should not be negative.\n" +
|
1840
|
-
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1867
|
+
"<-0.1> was expected to be\n>=\n<0.0>.") do
|
1841
1868
|
assert_in_epsilon(10000, 9000, -0.1, "message")
|
1842
1869
|
end
|
1843
1870
|
end
|
1844
1871
|
|
1845
1872
|
def test_fail_without_epsilon
|
1846
1873
|
check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
|
1847
|
-
"expected to include\n" +
|
1874
|
+
"was expected to include\n" +
|
1848
1875
|
"<10011>.\n" +
|
1849
1876
|
"\n" +
|
1850
1877
|
"Relation:\n" +
|
@@ -1897,7 +1924,7 @@ MESSAGE
|
|
1897
1924
|
|
1898
1925
|
def test_fail
|
1899
1926
|
check_fail("<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1900
|
-
"expected to not include\n" +
|
1927
|
+
"was expected to not include\n" +
|
1901
1928
|
"<9000>.\n" +
|
1902
1929
|
"\n" +
|
1903
1930
|
"Relation:\n" +
|
@@ -1912,7 +1939,7 @@ MESSAGE
|
|
1912
1939
|
|
1913
1940
|
def test_fail_without_epsilon
|
1914
1941
|
check_fail("<10000> -/+ (<10000> * <0.001>)[10.0] " +
|
1915
|
-
"expected to not include\n" +
|
1942
|
+
"was expected to not include\n" +
|
1916
1943
|
"<9990>.\n" +
|
1917
1944
|
"\n" +
|
1918
1945
|
"Relation:\n" +
|
@@ -1928,7 +1955,7 @@ MESSAGE
|
|
1928
1955
|
def test_fail_with_message
|
1929
1956
|
check_fail("message.\n" +
|
1930
1957
|
"<10000> -/+ (<10000> * <0.1>)[1000.0] " +
|
1931
|
-
"expected to not include\n" +
|
1958
|
+
"was expected to not include\n" +
|
1932
1959
|
"<9000>.\n" +
|
1933
1960
|
"\n" +
|
1934
1961
|
"Relation:\n" +
|
@@ -1954,7 +1981,7 @@ MESSAGE
|
|
1954
1981
|
|
1955
1982
|
def test_fail_because_negaitve_epsilon
|
1956
1983
|
check_fail("The epsilon should not be negative.\n" +
|
1957
|
-
"<-0.1> expected to be\n>=\n<0.0>.") do
|
1984
|
+
"<-0.1> was expected to be\n>=\n<0.0>.") do
|
1958
1985
|
assert_not_in_epsilon(10000, 9000, -0.1, "message")
|
1959
1986
|
end
|
1960
1987
|
end
|
@@ -1976,7 +2003,7 @@ MESSAGE
|
|
1976
2003
|
end
|
1977
2004
|
|
1978
2005
|
def test_fail
|
1979
|
-
check_fail("<[1, 2, 3]> expected to include\n" +
|
2006
|
+
check_fail("<[1, 2, 3]> was expected to include\n" +
|
1980
2007
|
"<4>.") do
|
1981
2008
|
assert_include([1, 2, 3], 4)
|
1982
2009
|
end
|
@@ -1984,7 +2011,7 @@ MESSAGE
|
|
1984
2011
|
|
1985
2012
|
def test_fail_with_message
|
1986
2013
|
check_fail("message.\n" +
|
1987
|
-
"<[1, 2, 3]> expected to include\n" +
|
2014
|
+
"<[1, 2, 3]> was expected to include\n" +
|
1988
2015
|
"<4>.") do
|
1989
2016
|
assert_include([1, 2, 3], 4, "message")
|
1990
2017
|
end
|
@@ -2017,7 +2044,7 @@ MESSAGE
|
|
2017
2044
|
end
|
2018
2045
|
|
2019
2046
|
def test_fail
|
2020
|
-
check_fail("<[1, 2, 3]> expected to not include\n" +
|
2047
|
+
check_fail("<[1, 2, 3]> was expected to not include\n" +
|
2021
2048
|
"<2>.") do
|
2022
2049
|
assert_not_include([1, 2, 3], 2)
|
2023
2050
|
end
|
@@ -2025,7 +2052,7 @@ MESSAGE
|
|
2025
2052
|
|
2026
2053
|
def test_fail_with_message
|
2027
2054
|
check_fail("message.\n" +
|
2028
|
-
"<[1, 2, 3]> expected to not include\n" +
|
2055
|
+
"<[1, 2, 3]> was expected to not include\n" +
|
2029
2056
|
"<2>.") do
|
2030
2057
|
assert_not_include([1, 2, 3], 2, "message")
|
2031
2058
|
end
|
@@ -2058,14 +2085,14 @@ MESSAGE
|
|
2058
2085
|
end
|
2059
2086
|
|
2060
2087
|
def test_fail
|
2061
|
-
check_fail("<[1]> expected to be empty.") do
|
2088
|
+
check_fail("<[1]> was expected to be empty.") do
|
2062
2089
|
assert_empty([1])
|
2063
2090
|
end
|
2064
2091
|
end
|
2065
2092
|
|
2066
2093
|
def test_fail_with_message
|
2067
2094
|
check_fail("message.\n" +
|
2068
|
-
"<[1]> expected to be empty.") do
|
2095
|
+
"<[1]> was expected to be empty.") do
|
2069
2096
|
assert_empty([1], "message")
|
2070
2097
|
end
|
2071
2098
|
end
|
@@ -2097,14 +2124,14 @@ MESSAGE
|
|
2097
2124
|
end
|
2098
2125
|
|
2099
2126
|
def test_fail
|
2100
|
-
check_fail("<[]> expected to not be empty.") do
|
2127
|
+
check_fail("<[]> was expected to not be empty.") do
|
2101
2128
|
assert_not_empty([])
|
2102
2129
|
end
|
2103
2130
|
end
|
2104
2131
|
|
2105
2132
|
def test_fail_with_message
|
2106
2133
|
check_fail("message.\n" +
|
2107
|
-
"<[]> expected to not be empty.") do
|
2134
|
+
"<[]> was expected to not be empty.") do
|
2108
2135
|
assert_not_empty([], "message")
|
2109
2136
|
end
|
2110
2137
|
end
|
@@ -2132,7 +2159,7 @@ MESSAGE
|
|
2132
2159
|
def test_fail
|
2133
2160
|
expected_message = <<-EOM
|
2134
2161
|
message.
|
2135
|
-
<[1, 2]> expected to respond to
|
2162
|
+
<[1, 2]> was expected to respond to
|
2136
2163
|
<member?(*[2])> with not a true value but was
|
2137
2164
|
<true>.
|
2138
2165
|
EOM
|