assert 2.15.2 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/assert/assertions.rb +6 -0
- data/lib/assert/config_helpers.rb +35 -14
- data/lib/assert/context.rb +36 -43
- data/lib/assert/context/test_dsl.rb +4 -4
- data/lib/assert/default_suite.rb +35 -40
- data/lib/assert/default_view.rb +109 -37
- data/lib/assert/file_line.rb +1 -1
- data/lib/assert/result.rb +67 -27
- data/lib/assert/runner.rb +14 -10
- data/lib/assert/suite.rb +41 -50
- data/lib/assert/test.rb +39 -81
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view_helpers.rb +11 -21
- data/test/helper.rb +40 -0
- data/test/system/test_tests.rb +90 -88
- data/test/unit/assertions/assert_block_tests.rb +14 -10
- data/test/unit/assertions/assert_empty_tests.rb +14 -10
- data/test/unit/assertions/assert_equal_tests.rb +22 -14
- data/test/unit/assertions/assert_file_exists_tests.rb +14 -10
- data/test/unit/assertions/assert_includes_tests.rb +14 -10
- data/test/unit/assertions/assert_instance_of_tests.rb +14 -10
- data/test/unit/assertions/assert_kind_of_tests.rb +14 -10
- data/test/unit/assertions/assert_match_tests.rb +14 -10
- data/test/unit/assertions/assert_nil_tests.rb +14 -10
- data/test/unit/assertions/assert_raises_tests.rb +14 -10
- data/test/unit/assertions/assert_respond_to_tests.rb +14 -10
- data/test/unit/assertions/assert_same_tests.rb +20 -14
- data/test/unit/assertions/assert_true_false_tests.rb +28 -20
- data/test/unit/assertions_tests.rb +12 -9
- data/test/unit/config_helpers_tests.rb +72 -13
- data/test/unit/context/test_dsl_tests.rb +38 -45
- data/test/unit/context_tests.rb +12 -8
- data/test/unit/default_suite_tests.rb +66 -43
- data/test/unit/file_line_tests.rb +4 -1
- data/test/unit/result_tests.rb +71 -47
- data/test/unit/runner_tests.rb +34 -16
- data/test/unit/suite_tests.rb +61 -29
- data/test/unit/test_tests.rb +97 -134
- data/test/unit/view_helpers_tests.rb +17 -31
- metadata +2 -2
@@ -6,6 +6,8 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertKindOfTests < Assert::Context
|
9
|
+
include Assert::Test::TestHelpers
|
10
|
+
|
9
11
|
desc "`assert_kind_of`"
|
10
12
|
setup do
|
11
13
|
desc = @desc = "assert kind of fail desc"
|
@@ -15,25 +17,27 @@ module Assert::Assertions
|
|
15
17
|
assert_kind_of(*args) # fail
|
16
18
|
end
|
17
19
|
@c = @test.config
|
18
|
-
@test.run
|
20
|
+
@test.run(&test_run_callback)
|
19
21
|
end
|
20
22
|
subject{ @test }
|
21
23
|
|
22
24
|
should "produce results as expected" do
|
23
|
-
assert_equal 2,
|
24
|
-
assert_equal 1,
|
25
|
-
assert_equal 1,
|
25
|
+
assert_equal 2, test_run_result_count
|
26
|
+
assert_equal 1, test_run_result_count(:pass)
|
27
|
+
assert_equal 1, test_run_result_count(:fail)
|
26
28
|
end
|
27
29
|
|
28
30
|
should "have a fail message with custom and generic explanations" do
|
29
31
|
exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
|
30
32
|
" to be a kind of #{@args[0]}."
|
31
|
-
assert_equal exp,
|
33
|
+
assert_equal exp, test_run_results(:fail).first.message
|
32
34
|
end
|
33
35
|
|
34
36
|
end
|
35
37
|
|
36
38
|
class AssertNotKindOfTests < Assert::Context
|
39
|
+
include Assert::Test::TestHelpers
|
40
|
+
|
37
41
|
desc "`assert_not_kind_of`"
|
38
42
|
setup do
|
39
43
|
desc = @desc = "assert not kind of fail desc"
|
@@ -43,20 +47,20 @@ module Assert::Assertions
|
|
43
47
|
assert_not_kind_of(Array, "object") # pass
|
44
48
|
end
|
45
49
|
@c = @test.config
|
46
|
-
@test.run
|
50
|
+
@test.run(&test_run_callback)
|
47
51
|
end
|
48
52
|
subject{ @test }
|
49
53
|
|
50
54
|
should "produce results as expected" do
|
51
|
-
assert_equal 2,
|
52
|
-
assert_equal 1,
|
53
|
-
assert_equal 1,
|
55
|
+
assert_equal 2, test_run_result_count
|
56
|
+
assert_equal 1, test_run_result_count(:pass)
|
57
|
+
assert_equal 1, test_run_result_count(:fail)
|
54
58
|
end
|
55
59
|
|
56
60
|
should "have a fail message with custom and generic explanations" do
|
57
61
|
exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
|
58
62
|
" to not be a kind of #{@args[0]}."
|
59
|
-
assert_equal exp,
|
63
|
+
assert_equal exp, test_run_results(:fail).first.message
|
60
64
|
end
|
61
65
|
|
62
66
|
end
|
@@ -6,6 +6,8 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertMatchTests < Assert::Context
|
9
|
+
include Assert::Test::TestHelpers
|
10
|
+
|
9
11
|
desc "`assert_match`"
|
10
12
|
setup do
|
11
13
|
desc = @desc = "assert match fail desc"
|
@@ -15,25 +17,27 @@ module Assert::Assertions
|
|
15
17
|
assert_match(*args) # fail
|
16
18
|
end
|
17
19
|
@c = @test.config
|
18
|
-
@test.run
|
20
|
+
@test.run(&test_run_callback)
|
19
21
|
end
|
20
22
|
subject{ @test }
|
21
23
|
|
22
24
|
should "produce results as expected" do
|
23
|
-
assert_equal 2,
|
24
|
-
assert_equal 1,
|
25
|
-
assert_equal 1,
|
25
|
+
assert_equal 2, test_run_result_count
|
26
|
+
assert_equal 1, test_run_result_count(:pass)
|
27
|
+
assert_equal 1, test_run_result_count(:fail)
|
26
28
|
end
|
27
29
|
|
28
30
|
should "have a fail message with custom and generic explanations" do
|
29
31
|
exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)}"\
|
30
32
|
" to match #{Assert::U.show(@args[0], @c)}."
|
31
|
-
assert_equal exp,
|
33
|
+
assert_equal exp, test_run_results(:fail).first.message
|
32
34
|
end
|
33
35
|
|
34
36
|
end
|
35
37
|
|
36
38
|
class AssertNotMatchTests < Assert::Context
|
39
|
+
include Assert::Test::TestHelpers
|
40
|
+
|
37
41
|
desc "`assert_not_match`"
|
38
42
|
setup do
|
39
43
|
desc = @desc = "assert not match fail desc"
|
@@ -43,20 +47,20 @@ module Assert::Assertions
|
|
43
47
|
assert_not_match("not", "a string") # pass
|
44
48
|
end
|
45
49
|
@c = @test.config
|
46
|
-
@test.run
|
50
|
+
@test.run(&test_run_callback)
|
47
51
|
end
|
48
52
|
subject{ @test }
|
49
53
|
|
50
54
|
should "produce results as expected" do
|
51
|
-
assert_equal 2,
|
52
|
-
assert_equal 1,
|
53
|
-
assert_equal 1,
|
55
|
+
assert_equal 2, test_run_result_count
|
56
|
+
assert_equal 1, test_run_result_count(:pass)
|
57
|
+
assert_equal 1, test_run_result_count(:fail)
|
54
58
|
end
|
55
59
|
|
56
60
|
should "have a fail message with custom and generic explanations" do
|
57
61
|
exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)}"\
|
58
62
|
" to not match #{Assert::U.show(@args[0], @c)}."
|
59
|
-
assert_equal exp,
|
63
|
+
assert_equal exp, test_run_results(:fail).first.message
|
60
64
|
end
|
61
65
|
|
62
66
|
end
|
@@ -6,6 +6,8 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertNilTests < Assert::Context
|
9
|
+
include Assert::Test::TestHelpers
|
10
|
+
|
9
11
|
desc "`assert_nil`"
|
10
12
|
setup do
|
11
13
|
desc = @desc = "assert nil empty fail desc"
|
@@ -15,24 +17,26 @@ module Assert::Assertions
|
|
15
17
|
assert_nil(*args) # fail
|
16
18
|
end
|
17
19
|
@c = @test.config
|
18
|
-
@test.run
|
20
|
+
@test.run(&test_run_callback)
|
19
21
|
end
|
20
22
|
subject{ @test }
|
21
23
|
|
22
24
|
should "produce results as expected" do
|
23
|
-
assert_equal 2,
|
24
|
-
assert_equal 1,
|
25
|
-
assert_equal 1,
|
25
|
+
assert_equal 2, test_run_result_count
|
26
|
+
assert_equal 1, test_run_result_count(:pass)
|
27
|
+
assert_equal 1, test_run_result_count(:fail)
|
26
28
|
end
|
27
29
|
|
28
30
|
should "have a fail message with custom and generic explanations" do
|
29
31
|
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be nil."
|
30
|
-
assert_equal exp,
|
32
|
+
assert_equal exp, test_run_results(:fail).first.message
|
31
33
|
end
|
32
34
|
|
33
35
|
end
|
34
36
|
|
35
37
|
class AssertNotNilTests < Assert::Context
|
38
|
+
include Assert::Test::TestHelpers
|
39
|
+
|
36
40
|
desc "`assert_not_nil`"
|
37
41
|
setup do
|
38
42
|
desc = @desc = "assert not nil empty fail desc"
|
@@ -42,19 +46,19 @@ module Assert::Assertions
|
|
42
46
|
assert_not_nil(*args) # fail
|
43
47
|
end
|
44
48
|
@c = @test.config
|
45
|
-
@test.run
|
49
|
+
@test.run(&test_run_callback)
|
46
50
|
end
|
47
51
|
subject{ @test }
|
48
52
|
|
49
53
|
should "produce results as expected" do
|
50
|
-
assert_equal 2,
|
51
|
-
assert_equal 1,
|
52
|
-
assert_equal 1,
|
54
|
+
assert_equal 2, test_run_result_count
|
55
|
+
assert_equal 1, test_run_result_count(:pass)
|
56
|
+
assert_equal 1, test_run_result_count(:fail)
|
53
57
|
end
|
54
58
|
|
55
59
|
should "have a fail message with custom and generic explanations" do
|
56
60
|
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be nil."
|
57
|
-
assert_equal exp,
|
61
|
+
assert_equal exp, test_run_results(:fail).first.message
|
58
62
|
end
|
59
63
|
|
60
64
|
end
|
@@ -4,6 +4,8 @@ require 'assert/assertions'
|
|
4
4
|
module Assert::Assertions
|
5
5
|
|
6
6
|
class AssertRaisesTests < Assert::Context
|
7
|
+
include Assert::Test::TestHelpers
|
8
|
+
|
7
9
|
desc "`assert_raises`"
|
8
10
|
setup do
|
9
11
|
d = @d = "assert raises fail desc"
|
@@ -14,14 +16,14 @@ module Assert::Assertions
|
|
14
16
|
assert_raises(RuntimeError, d){ true } # fail
|
15
17
|
assert_raises(d){ true } # fail
|
16
18
|
end
|
17
|
-
@test.run
|
19
|
+
@test.run(&test_run_callback)
|
18
20
|
end
|
19
21
|
subject{ @test }
|
20
22
|
|
21
23
|
should "produce results as expected" do
|
22
|
-
assert_equal 5,
|
23
|
-
assert_equal 1,
|
24
|
-
assert_equal 4,
|
24
|
+
assert_equal 5, test_run_result_count
|
25
|
+
assert_equal 1, test_run_result_count(:pass)
|
26
|
+
assert_equal 4, test_run_result_count(:fail)
|
25
27
|
end
|
26
28
|
|
27
29
|
should "have a fail message with custom and generic explanations" do
|
@@ -31,7 +33,7 @@ module Assert::Assertions
|
|
31
33
|
"#{@d}\nRuntimeError exception expected but nothing raised.",
|
32
34
|
"#{@d}\nAn exception expected but nothing raised."
|
33
35
|
]
|
34
|
-
messages =
|
36
|
+
messages = test_run_results(:fail).map(&:message)
|
35
37
|
messages.each_with_index{ |msg, n| assert_match /^#{exp[n]}/, msg }
|
36
38
|
end
|
37
39
|
|
@@ -58,6 +60,8 @@ module Assert::Assertions
|
|
58
60
|
end
|
59
61
|
|
60
62
|
class AssertNothingRaisedTests < Assert::Context
|
63
|
+
include Assert::Test::TestHelpers
|
64
|
+
|
61
65
|
desc "`assert_nothing_raised`"
|
62
66
|
setup do
|
63
67
|
d = @d = "assert nothing raised fail desc"
|
@@ -68,14 +72,14 @@ module Assert::Assertions
|
|
68
72
|
self.send(anr, d){ raise(RuntimeError) } # fail
|
69
73
|
self.send(anr){ true } # pass
|
70
74
|
end
|
71
|
-
@test.run
|
75
|
+
@test.run(&test_run_callback)
|
72
76
|
end
|
73
77
|
subject{ @test }
|
74
78
|
|
75
79
|
should "produce results as expected" do
|
76
|
-
assert_equal 4,
|
77
|
-
assert_equal 2,
|
78
|
-
assert_equal 2,
|
80
|
+
assert_equal 4, test_run_result_count
|
81
|
+
assert_equal 2, test_run_result_count(:pass)
|
82
|
+
assert_equal 2, test_run_result_count(:fail)
|
79
83
|
end
|
80
84
|
|
81
85
|
should "have a fail message with custom and generic explanations" do
|
@@ -83,7 +87,7 @@ module Assert::Assertions
|
|
83
87
|
"#{@d}\nStandardError or RuntimeError exception not expected, but raised:",
|
84
88
|
"#{@d}\nAn exception not expected, but raised:"
|
85
89
|
]
|
86
|
-
messages =
|
90
|
+
messages = test_run_results(:fail).map(&:message)
|
87
91
|
messages.each_with_index{ |msg, n| assert_match /^#{exp[n]}/, msg }
|
88
92
|
end
|
89
93
|
|
@@ -6,6 +6,8 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertRespondToTests < Assert::Context
|
9
|
+
include Assert::Test::TestHelpers
|
10
|
+
|
9
11
|
desc "`assert_respond_to`"
|
10
12
|
setup do
|
11
13
|
desc = @desc = "assert respond to fail desc"
|
@@ -15,26 +17,28 @@ module Assert::Assertions
|
|
15
17
|
assert_respond_to(*args) # fail
|
16
18
|
end
|
17
19
|
@c = @test.config
|
18
|
-
@test.run
|
20
|
+
@test.run(&test_run_callback)
|
19
21
|
end
|
20
22
|
subject{ @test }
|
21
23
|
|
22
24
|
should "produce results as expected" do
|
23
|
-
assert_equal 2,
|
24
|
-
assert_equal 1,
|
25
|
-
assert_equal 1,
|
25
|
+
assert_equal 2, test_run_result_count
|
26
|
+
assert_equal 1, test_run_result_count(:pass)
|
27
|
+
assert_equal 1, test_run_result_count(:fail)
|
26
28
|
end
|
27
29
|
|
28
30
|
should "have a fail message with custom and generic explanations" do
|
29
31
|
exp = "#{@args[2]}\n"\
|
30
32
|
"Expected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
|
31
33
|
" to respond to `#{@args[0]}`."
|
32
|
-
assert_equal exp,
|
34
|
+
assert_equal exp, test_run_results(:fail).first.message
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
36
38
|
|
37
39
|
class AssertNotRespondToTests < Assert::Context
|
40
|
+
include Assert::Test::TestHelpers
|
41
|
+
|
38
42
|
desc "`assert_not_respond_to`"
|
39
43
|
setup do
|
40
44
|
desc = @desc = "assert not respond to fail desc"
|
@@ -44,21 +48,21 @@ module Assert::Assertions
|
|
44
48
|
assert_not_respond_to(:abs, "1") # pass
|
45
49
|
end
|
46
50
|
@c = @test.config
|
47
|
-
@test.run
|
51
|
+
@test.run(&test_run_callback)
|
48
52
|
end
|
49
53
|
subject{ @test }
|
50
54
|
|
51
55
|
should "produce results as expected" do
|
52
|
-
assert_equal 2,
|
53
|
-
assert_equal 1,
|
54
|
-
assert_equal 1,
|
56
|
+
assert_equal 2, test_run_result_count
|
57
|
+
assert_equal 1, test_run_result_count(:pass)
|
58
|
+
assert_equal 1, test_run_result_count(:fail)
|
55
59
|
end
|
56
60
|
|
57
61
|
should "have a fail message with custom and generic explanations" do
|
58
62
|
exp = "#{@args[2]}\n"\
|
59
63
|
"Expected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
|
60
64
|
" to not respond to `#{@args[0]}`."
|
61
|
-
assert_equal exp,
|
65
|
+
assert_equal exp, test_run_results(:fail).first.message
|
62
66
|
end
|
63
67
|
|
64
68
|
end
|
@@ -6,6 +6,8 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertSameTests < Assert::Context
|
9
|
+
include Assert::Test::TestHelpers
|
10
|
+
|
9
11
|
desc "`assert_same`"
|
10
12
|
setup do
|
11
13
|
klass = Class.new; object = klass.new
|
@@ -16,14 +18,14 @@ module Assert::Assertions
|
|
16
18
|
assert_same(*args) # fail
|
17
19
|
end
|
18
20
|
@c = @test.config
|
19
|
-
@test.run
|
21
|
+
@test.run(&test_run_callback)
|
20
22
|
end
|
21
23
|
subject{ @test }
|
22
24
|
|
23
25
|
should "produce results as expected" do
|
24
|
-
assert_equal 2,
|
25
|
-
assert_equal 1,
|
26
|
-
assert_equal 1,
|
26
|
+
assert_equal 2, test_run_result_count
|
27
|
+
assert_equal 1, test_run_result_count(:pass)
|
28
|
+
assert_equal 1, test_run_result_count(:fail)
|
27
29
|
end
|
28
30
|
|
29
31
|
should "have a fail message with custom and generic explanations" do
|
@@ -32,12 +34,14 @@ module Assert::Assertions
|
|
32
34
|
" (#<#{@args[1].class}:#{'0x0%x' % (@args[1].object_id << 1)}>)"\
|
33
35
|
" to be the same as #{Assert::U.show(@args[0], @c)}"\
|
34
36
|
" (#<#{@args[0].class}:#{'0x0%x' % (@args[0].object_id << 1)}>)."
|
35
|
-
assert_equal exp,
|
37
|
+
assert_equal exp, test_run_results(:fail).first.message
|
36
38
|
end
|
37
39
|
|
38
40
|
end
|
39
41
|
|
40
42
|
class AssertNotSameTests < Assert::Context
|
43
|
+
include Assert::Test::TestHelpers
|
44
|
+
|
41
45
|
desc "`assert_not_same`"
|
42
46
|
setup do
|
43
47
|
klass = Class.new; object = klass.new
|
@@ -48,14 +52,14 @@ module Assert::Assertions
|
|
48
52
|
assert_not_same(object, klass.new) # pass
|
49
53
|
end
|
50
54
|
@c = @test.config
|
51
|
-
@test.run
|
55
|
+
@test.run(&test_run_callback)
|
52
56
|
end
|
53
57
|
subject{ @test }
|
54
58
|
|
55
59
|
should "produce results as expected" do
|
56
|
-
assert_equal 2,
|
57
|
-
assert_equal 1,
|
58
|
-
assert_equal 1,
|
60
|
+
assert_equal 2, test_run_result_count
|
61
|
+
assert_equal 1, test_run_result_count(:pass)
|
62
|
+
assert_equal 1, test_run_result_count(:fail)
|
59
63
|
end
|
60
64
|
|
61
65
|
should "have a fail message with custom and generic explanations" do
|
@@ -64,12 +68,14 @@ module Assert::Assertions
|
|
64
68
|
" (#<#{@args[1].class}:#{'0x0%x' % (@args[1].object_id << 1)}>)"\
|
65
69
|
" to not be the same as #{Assert::U.show(@args[0], @c)}"\
|
66
70
|
" (#<#{@args[0].class}:#{'0x0%x' % (@args[0].object_id << 1)}>)."
|
67
|
-
assert_equal exp,
|
71
|
+
assert_equal exp, test_run_results(:fail).first.message
|
68
72
|
end
|
69
73
|
|
70
74
|
end
|
71
75
|
|
72
76
|
class DiffTests < Assert::Context
|
77
|
+
include Assert::Test::TestHelpers
|
78
|
+
|
73
79
|
desc "with objects that should use diff when showing"
|
74
80
|
setup do
|
75
81
|
@exp_obj = "I'm a\nstring"
|
@@ -92,7 +98,7 @@ module Assert::Assertions
|
|
92
98
|
@test = Factory.test(@c) do
|
93
99
|
assert_same(exp_obj, act_obj)
|
94
100
|
end
|
95
|
-
@test.run
|
101
|
+
@test.run(&test_run_callback)
|
96
102
|
end
|
97
103
|
subject{ @test }
|
98
104
|
|
@@ -102,7 +108,7 @@ module Assert::Assertions
|
|
102
108
|
" #<#{@exp_obj.class}:#{'0x0%x' % (@exp_obj.object_id << 1)}>"\
|
103
109
|
", diff:\n"\
|
104
110
|
"#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @act_obj_show)}"
|
105
|
-
assert_equal exp,
|
111
|
+
assert_equal exp, test_run_results(:fail).first.message
|
106
112
|
end
|
107
113
|
|
108
114
|
end
|
@@ -117,7 +123,7 @@ module Assert::Assertions
|
|
117
123
|
@test = Factory.test(@c) do
|
118
124
|
assert_not_same(exp_obj, exp_obj)
|
119
125
|
end
|
120
|
-
@test.run
|
126
|
+
@test.run(&test_run_callback)
|
121
127
|
end
|
122
128
|
subject{ @test }
|
123
129
|
|
@@ -127,7 +133,7 @@ module Assert::Assertions
|
|
127
133
|
" #<#{@exp_obj.class}:#{'0x0%x' % (@exp_obj.object_id << 1)}>"\
|
128
134
|
", diff:\n"\
|
129
135
|
"#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @act_obj_show)}"
|
130
|
-
assert_equal exp,
|
136
|
+
assert_equal exp, test_run_results(:fail).first.message
|
131
137
|
end
|
132
138
|
|
133
139
|
end
|