assert 2.19.1 → 2.19.6
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 +4 -4
- data/assert.gemspec +10 -7
- data/lib/assert.rb +18 -6
- data/lib/assert/actual_value.rb +8 -6
- data/lib/assert/assert_runner.rb +36 -17
- data/lib/assert/assertions.rb +83 -50
- data/lib/assert/cli.rb +30 -70
- data/lib/assert/clirb.rb +55 -0
- data/lib/assert/config.rb +20 -8
- data/lib/assert/config_helpers.rb +55 -22
- data/lib/assert/context.rb +14 -18
- data/lib/assert/context/let_dsl.rb +5 -2
- data/lib/assert/context/setup_dsl.rb +21 -16
- data/lib/assert/context/subject_dsl.rb +6 -7
- data/lib/assert/context/suite_dsl.rb +2 -1
- data/lib/assert/context/test_dsl.rb +55 -19
- data/lib/assert/default_suite.rb +25 -15
- data/lib/assert/default_view.rb +47 -30
- data/lib/assert/file_line.rb +6 -6
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +71 -45
- data/lib/assert/result.rb +111 -62
- data/lib/assert/runner.rb +68 -51
- data/lib/assert/stub.rb +42 -3
- data/lib/assert/suite.rb +67 -28
- data/lib/assert/test.rb +40 -35
- data/lib/assert/utils.rb +19 -10
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +44 -18
- data/lib/assert/view_helpers.rb +100 -92
- data/test/helper.rb +3 -1
- data/test/support/factory.rb +38 -21
- data/test/system/stub_tests.rb +180 -144
- data/test/system/test_tests.rb +86 -60
- data/test/unit/actual_value_tests.rb +69 -50
- data/test/unit/assert_tests.rb +39 -22
- data/test/unit/assertions/assert_block_tests.rb +10 -10
- data/test/unit/assertions/assert_changes_tests.rb +25 -21
- data/test/unit/assertions/assert_empty_tests.rb +14 -12
- data/test/unit/assertions/assert_equal_tests.rb +26 -26
- data/test/unit/assertions/assert_file_exists_tests.rb +15 -13
- data/test/unit/assertions/assert_includes_tests.rb +10 -10
- data/test/unit/assertions/assert_instance_of_tests.rb +14 -14
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +10 -10
- data/test/unit/assertions/assert_nil_tests.rb +16 -12
- data/test/unit/assertions/assert_raises_tests.rb +27 -20
- data/test/unit/assertions/assert_respond_to_tests.rb +10 -10
- data/test/unit/assertions/assert_same_tests.rb +24 -24
- data/test/unit/assertions/assert_true_false_tests.rb +32 -24
- data/test/unit/assertions_tests.rb +14 -9
- data/test/unit/config_helpers_tests.rb +15 -10
- data/test/unit/config_tests.rb +34 -9
- data/test/unit/context/setup_dsl_tests.rb +24 -14
- data/test/unit/context/subject_dsl_tests.rb +3 -3
- data/test/unit/context/suite_dsl_tests.rb +4 -4
- data/test/unit/context/test_dsl_tests.rb +37 -17
- data/test/unit/context_info_tests.rb +4 -4
- data/test/unit/context_tests.rb +110 -54
- data/test/unit/default_suite_tests.rb +10 -6
- data/test/unit/factory_tests.rb +2 -2
- data/test/unit/file_line_tests.rb +7 -7
- data/test/unit/macro_tests.rb +11 -11
- data/test/unit/result_tests.rb +47 -41
- data/test/unit/runner_tests.rb +29 -16
- data/test/unit/suite_tests.rb +37 -15
- data/test/unit/test_tests.rb +63 -50
- data/test/unit/utils_tests.rb +48 -35
- data/test/unit/view_helpers_tests.rb +21 -14
- data/test/unit/view_tests.rb +5 -5
- metadata +26 -11
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
@@ -6,22 +6,21 @@ require "assert/assertions"
|
|
6
6
|
require "assert/utils"
|
7
7
|
|
8
8
|
module Assert::Assertions
|
9
|
-
|
10
9
|
class AssertFileExistsTests < Assert::Context
|
11
10
|
include Assert::Test::TestHelpers
|
12
11
|
|
13
12
|
desc "`assert_file_exists`"
|
14
|
-
subject
|
13
|
+
subject do
|
15
14
|
args = args1
|
16
15
|
Factory.test do
|
17
16
|
assert_file_exists(__FILE__) # pass
|
18
17
|
assert_file_exists(*args) # fail
|
19
18
|
end
|
20
|
-
|
19
|
+
end
|
21
20
|
|
22
|
-
let(:desc1)
|
23
|
-
let(:args1)
|
24
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert file exists fail desc" }
|
22
|
+
let(:args1){ ["/a/path/to/some/file/that/no/exists", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
25
24
|
|
26
25
|
should "produce results as expected" do
|
27
26
|
subject.run(&test_run_callback)
|
@@ -30,7 +29,8 @@ module Assert::Assertions
|
|
30
29
|
assert_that(test_run_result_count(:pass)).equals(1)
|
31
30
|
assert_that(test_run_result_count(:fail)).equals(1)
|
32
31
|
|
33
|
-
exp =
|
32
|
+
exp =
|
33
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to exist."
|
34
34
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
35
35
|
end
|
36
36
|
end
|
@@ -39,17 +39,17 @@ module Assert::Assertions
|
|
39
39
|
include Assert::Test::TestHelpers
|
40
40
|
|
41
41
|
desc "`assert_not_file_exists`"
|
42
|
-
subject
|
42
|
+
subject do
|
43
43
|
args = args1
|
44
44
|
Factory.test do
|
45
45
|
assert_not_file_exists("/file/path") # pass
|
46
46
|
assert_not_file_exists(*args) # fail
|
47
47
|
end
|
48
|
-
|
48
|
+
end
|
49
49
|
|
50
|
-
let(:desc1)
|
51
|
-
let(:args1)
|
52
|
-
let(:config1)
|
50
|
+
let(:desc1){ "assert not file exists fail desc" }
|
51
|
+
let(:args1){ [__FILE__, desc1] }
|
52
|
+
let(:config1){ subject.config }
|
53
53
|
|
54
54
|
should "produce results as expected" do
|
55
55
|
subject.run(&test_run_callback)
|
@@ -58,7 +58,9 @@ module Assert::Assertions
|
|
58
58
|
assert_that(test_run_result_count(:pass)).equals(1)
|
59
59
|
assert_that(test_run_result_count(:fail)).equals(1)
|
60
60
|
|
61
|
-
exp =
|
61
|
+
exp =
|
62
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
63
|
+
"not exist."
|
62
64
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
63
65
|
end
|
64
66
|
end
|
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_includes`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_includes(1, [1]) # pass
|
17
17
|
assert_includes(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert includes fail desc" }
|
22
|
+
let(:args1){ [2, [1], desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -41,17 +41,17 @@ module Assert::Assertions
|
|
41
41
|
include Assert::Test::TestHelpers
|
42
42
|
|
43
43
|
desc "`assert_not_included`"
|
44
|
-
subject
|
44
|
+
subject do
|
45
45
|
args = args1
|
46
46
|
Factory.test do
|
47
47
|
assert_not_included(2, [1]) # pass
|
48
48
|
assert_not_included(*args) # fail
|
49
49
|
end
|
50
|
-
|
50
|
+
end
|
51
51
|
|
52
|
-
let(:desc1)
|
53
|
-
let(:args1)
|
54
|
-
let(:config1)
|
52
|
+
let(:desc1){ "assert not included fail desc" }
|
53
|
+
let(:args1){ [1, [1], desc1] }
|
54
|
+
let(:config1){ subject.config }
|
55
55
|
|
56
56
|
should "produce results as expected" do
|
57
57
|
subject.run(&test_run_callback)
|
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_instance_of`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_instance_of(String, "object") # pass
|
17
17
|
assert_instance_of(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert instance of fail desc" }
|
22
|
+
let(:args1){ [Array, "object", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -30,8 +30,8 @@ module Assert::Assertions
|
|
30
30
|
assert_that(test_run_result_count(:fail)).equals(1)
|
31
31
|
|
32
32
|
exp =
|
33
|
-
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}
|
34
|
-
" to be an instance of #{args1[0]}."
|
33
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
34
|
+
"(#{args1[1].class}) to be an instance of #{args1[0]}."
|
35
35
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
36
36
|
end
|
37
37
|
end
|
@@ -40,17 +40,17 @@ module Assert::Assertions
|
|
40
40
|
include Assert::Test::TestHelpers
|
41
41
|
|
42
42
|
desc "`assert_not_instance_of`"
|
43
|
-
subject
|
43
|
+
subject do
|
44
44
|
args = args1
|
45
45
|
Factory.test do
|
46
46
|
assert_not_instance_of(*args) # fail
|
47
47
|
assert_not_instance_of(Array, "object") # pass
|
48
48
|
end
|
49
|
-
|
49
|
+
end
|
50
50
|
|
51
|
-
let(:desc1)
|
52
|
-
let(:args1)
|
53
|
-
let(:config1)
|
51
|
+
let(:desc1){ "assert not instance of fail desc" }
|
52
|
+
let(:args1){ [String, "object", desc1] }
|
53
|
+
let(:config1){ subject.config }
|
54
54
|
|
55
55
|
should "produce results as expected" do
|
56
56
|
subject.run(&test_run_callback)
|
@@ -60,8 +60,8 @@ module Assert::Assertions
|
|
60
60
|
assert_that(test_run_result_count(:fail)).equals(1)
|
61
61
|
|
62
62
|
exp =
|
63
|
-
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}
|
64
|
-
" to not be an instance of #{args1[0]}."
|
63
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
64
|
+
"(#{args1[1].class}) to not be an instance of #{args1[0]}."
|
65
65
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
66
66
|
end
|
67
67
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "assert"
|
4
|
+
require "assert/assertions"
|
5
|
+
|
6
|
+
require "assert/utils"
|
7
|
+
|
8
|
+
module Assert::Assertions
|
9
|
+
class AssertIsATests < Assert::Context
|
10
|
+
include Assert::Test::TestHelpers
|
11
|
+
|
12
|
+
desc "`assert_is_a`"
|
13
|
+
subject do
|
14
|
+
args = args1
|
15
|
+
Factory.test do
|
16
|
+
assert_is_a(String, "object") # pass
|
17
|
+
assert_is_a(*args) # fail
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:desc1){ "assert kind of fail desc" }
|
22
|
+
let(:args1){ [Array, "object", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
|
+
|
25
|
+
should "produce results as expected" do
|
26
|
+
subject.run(&test_run_callback)
|
27
|
+
|
28
|
+
assert_that(test_run_result_count).equals(2)
|
29
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
30
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
31
|
+
|
32
|
+
exp =
|
33
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
34
|
+
"(#{args1[1].class}) to be a `#{args1[0]}`."
|
35
|
+
assert_that(test_run_results(:fail).first.message).equals(exp)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class AssertIsNotATests < Assert::Context
|
40
|
+
include Assert::Test::TestHelpers
|
41
|
+
|
42
|
+
desc "`assert_not_kind_of`"
|
43
|
+
subject do
|
44
|
+
args = args1
|
45
|
+
Factory.test do
|
46
|
+
assert_is_not_a(*args) # fail
|
47
|
+
assert_is_not_a(Array, "object") # pass
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:desc1){ "assert not kind of fail desc" }
|
52
|
+
let(:args1){ [String, "object", desc1] }
|
53
|
+
let(:config1){ subject.config }
|
54
|
+
|
55
|
+
should "produce results as expected" do
|
56
|
+
subject.run(&test_run_callback)
|
57
|
+
|
58
|
+
assert_that(test_run_result_count).equals(2)
|
59
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
60
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
61
|
+
|
62
|
+
exp =
|
63
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
64
|
+
"(#{args1[1].class}) to not be a `#{args1[0]}`."
|
65
|
+
assert_that(test_run_results(:fail).first.message).equals(exp)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class AssertKindOfTests < Assert::Context
|
70
|
+
include Assert::Test::TestHelpers
|
71
|
+
|
72
|
+
desc "`assert_kind_of`"
|
73
|
+
subject do
|
74
|
+
args = args1
|
75
|
+
Factory.test do
|
76
|
+
assert_kind_of(String, "object") # pass
|
77
|
+
assert_kind_of(*args) # fail
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
let(:desc1){ "assert kind of fail desc" }
|
82
|
+
let(:args1){ [Array, "object", desc1] }
|
83
|
+
let(:config1){ subject.config }
|
84
|
+
|
85
|
+
should "produce results as expected" do
|
86
|
+
subject.run(&test_run_callback)
|
87
|
+
|
88
|
+
assert_that(test_run_result_count).equals(2)
|
89
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
90
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
91
|
+
|
92
|
+
exp =
|
93
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
94
|
+
"(#{args1[1].class}) to be a `#{args1[0]}`."
|
95
|
+
assert_that(test_run_results(:fail).first.message).equals(exp)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class AssertNotKindOfTests < Assert::Context
|
100
|
+
include Assert::Test::TestHelpers
|
101
|
+
|
102
|
+
desc "`assert_not_kind_of`"
|
103
|
+
subject do
|
104
|
+
args = args1
|
105
|
+
Factory.test do
|
106
|
+
assert_not_kind_of(*args) # fail
|
107
|
+
assert_not_kind_of(Array, "object") # pass
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
let(:desc1){ "assert not kind of fail desc" }
|
112
|
+
let(:args1){ [String, "object", desc1] }
|
113
|
+
let(:config1){ subject.config }
|
114
|
+
|
115
|
+
should "produce results as expected" do
|
116
|
+
subject.run(&test_run_callback)
|
117
|
+
|
118
|
+
assert_that(test_run_result_count).equals(2)
|
119
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
120
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
121
|
+
|
122
|
+
exp =
|
123
|
+
"#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} "\
|
124
|
+
"(#{args1[1].class}) to not be a `#{args1[0]}`."
|
125
|
+
assert_that(test_run_results(:fail).first.message).equals(exp)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_match`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_match(/a/, "a string") # pass
|
17
17
|
assert_match(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert match fail desc" }
|
22
|
+
let(:args1){ ["not", "a string", desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -40,17 +40,17 @@ module Assert::Assertions
|
|
40
40
|
include Assert::Test::TestHelpers
|
41
41
|
|
42
42
|
desc "`assert_not_match`"
|
43
|
-
subject
|
43
|
+
subject do
|
44
44
|
args = args1
|
45
45
|
Factory.test do
|
46
46
|
assert_not_match(*args) # fail
|
47
47
|
assert_not_match("not", "a string") # pass
|
48
48
|
end
|
49
|
-
|
49
|
+
end
|
50
50
|
|
51
|
-
let(:desc1)
|
52
|
-
let(:args1)
|
53
|
-
let(:config1)
|
51
|
+
let(:desc1){ "assert not match fail desc" }
|
52
|
+
let(:args1){ [/a/, "a string", desc1] }
|
53
|
+
let(:config1){ subject.config }
|
54
54
|
|
55
55
|
should "produce results as expected" do
|
56
56
|
subject.run(&test_run_callback)
|
@@ -10,17 +10,17 @@ module Assert::Assertions
|
|
10
10
|
include Assert::Test::TestHelpers
|
11
11
|
|
12
12
|
desc "`assert_nil`"
|
13
|
-
subject
|
13
|
+
subject do
|
14
14
|
args = args1
|
15
15
|
Factory.test do
|
16
16
|
assert_nil(nil) # pass
|
17
17
|
assert_nil(*args) # fail
|
18
18
|
end
|
19
|
-
|
19
|
+
end
|
20
20
|
|
21
|
-
let(:desc1)
|
22
|
-
let(:args1)
|
23
|
-
let(:config1)
|
21
|
+
let(:desc1){ "assert nil empty fail desc" }
|
22
|
+
let(:args1){ [1, desc1] }
|
23
|
+
let(:config1){ subject.config }
|
24
24
|
|
25
25
|
should "produce results as expected" do
|
26
26
|
subject.run(&test_run_callback)
|
@@ -29,7 +29,9 @@ module Assert::Assertions
|
|
29
29
|
assert_that(test_run_result_count(:pass)).equals(1)
|
30
30
|
assert_that(test_run_result_count(:fail)).equals(1)
|
31
31
|
|
32
|
-
exp =
|
32
|
+
exp =
|
33
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
34
|
+
"be nil."
|
33
35
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
34
36
|
end
|
35
37
|
end
|
@@ -38,17 +40,17 @@ module Assert::Assertions
|
|
38
40
|
include Assert::Test::TestHelpers
|
39
41
|
|
40
42
|
desc "`assert_not_nil`"
|
41
|
-
subject
|
43
|
+
subject do
|
42
44
|
args = args1
|
43
45
|
Factory.test do
|
44
46
|
assert_not_nil(1) # pass
|
45
47
|
assert_not_nil(*args) # fail
|
46
48
|
end
|
47
|
-
|
49
|
+
end
|
48
50
|
|
49
|
-
let(:desc1)
|
50
|
-
let(:args1)
|
51
|
-
let(:config1)
|
51
|
+
let(:desc1){ "assert not nil empty fail desc" }
|
52
|
+
let(:args1){ [nil, desc1] }
|
53
|
+
let(:config1){ subject.config }
|
52
54
|
|
53
55
|
should "produce results as expected" do
|
54
56
|
subject.run(&test_run_callback)
|
@@ -57,7 +59,9 @@ module Assert::Assertions
|
|
57
59
|
assert_that(test_run_result_count(:pass)).equals(1)
|
58
60
|
assert_that(test_run_result_count(:fail)).equals(1)
|
59
61
|
|
60
|
-
exp =
|
62
|
+
exp =
|
63
|
+
"#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
|
64
|
+
"not be nil."
|
61
65
|
assert_that(test_run_results(:fail).first.message).equals(exp)
|
62
66
|
end
|
63
67
|
end
|
@@ -8,18 +8,18 @@ module Assert::Assertions
|
|
8
8
|
include Assert::Test::TestHelpers
|
9
9
|
|
10
10
|
desc "`assert_raises`"
|
11
|
-
subject
|
11
|
+
subject do
|
12
12
|
desc = desc1
|
13
13
|
Factory.test do
|
14
|
-
assert_raises(StandardError, RuntimeError)
|
15
|
-
assert_raises(StandardError, RuntimeError, desc)
|
16
|
-
assert_raises(RuntimeError, desc)
|
17
|
-
assert_raises(RuntimeError, desc)
|
18
|
-
assert_raises(desc)
|
14
|
+
assert_raises(StandardError, RuntimeError){ raise(StandardError) }
|
15
|
+
assert_raises(StandardError, RuntimeError, desc){ raise(Exception) }
|
16
|
+
assert_raises(RuntimeError, desc){ raise(StandardError) }
|
17
|
+
assert_raises(RuntimeError, desc){ true }
|
18
|
+
assert_raises(desc){ true }
|
19
19
|
end
|
20
|
-
|
20
|
+
end
|
21
21
|
|
22
|
-
let(:desc1)
|
22
|
+
let(:desc1){ "assert raises fail desc" }
|
23
23
|
|
24
24
|
should "produce results as expected" do
|
25
25
|
subject.run(&test_run_callback)
|
@@ -36,7 +36,9 @@ module Assert::Assertions
|
|
36
36
|
"#{desc1}\nAn exception expected but nothing raised.",
|
37
37
|
]
|
38
38
|
messages = test_run_results(:fail).map(&:message)
|
39
|
-
messages.each_with_index
|
39
|
+
messages.each_with_index do |msg, n|
|
40
|
+
assert_that(msg).matches(/^#{exp[n]}/)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
should "return any raised exception instance" do
|
@@ -45,7 +47,7 @@ module Assert::Assertions
|
|
45
47
|
|
46
48
|
test =
|
47
49
|
Factory.test do
|
48
|
-
error = assert_raises(RuntimeError)
|
50
|
+
error = assert_raises(RuntimeError){ raise(error_msg) }
|
49
51
|
end
|
50
52
|
test.run
|
51
53
|
|
@@ -53,7 +55,7 @@ module Assert::Assertions
|
|
53
55
|
assert_that(error).is_kind_of(RuntimeError)
|
54
56
|
assert_that(error.message).equals(error_msg)
|
55
57
|
|
56
|
-
test = Factory.test
|
58
|
+
test = Factory.test{ error = assert_raises(RuntimeError){} }
|
57
59
|
test.run
|
58
60
|
|
59
61
|
assert_that(error).is_nil
|
@@ -64,17 +66,19 @@ module Assert::Assertions
|
|
64
66
|
include Assert::Test::TestHelpers
|
65
67
|
|
66
68
|
desc "`assert_nothing_raised`"
|
67
|
-
subject
|
69
|
+
subject do
|
68
70
|
desc = desc1
|
69
71
|
Factory.test do
|
70
|
-
assert_nothing_raised(StandardError, RuntimeError, desc)
|
71
|
-
|
72
|
-
|
73
|
-
assert_nothing_raised
|
72
|
+
assert_nothing_raised(StandardError, RuntimeError, desc) do
|
73
|
+
raise(StandardError)
|
74
|
+
end
|
75
|
+
assert_nothing_raised(RuntimeError){ raise(StandardError) }
|
76
|
+
assert_nothing_raised(desc){ raise(RuntimeError) }
|
77
|
+
assert_nothing_raised{ true }
|
74
78
|
end
|
75
|
-
|
79
|
+
end
|
76
80
|
|
77
|
-
let(:desc1)
|
81
|
+
let(:desc1){ "assert nothing raised fail desc" }
|
78
82
|
|
79
83
|
should "produce results as expected" do
|
80
84
|
subject.run(&test_run_callback)
|
@@ -85,11 +89,14 @@ module Assert::Assertions
|
|
85
89
|
|
86
90
|
exp =
|
87
91
|
[
|
88
|
-
"#{desc1}\nStandardError or RuntimeError exception not expected,
|
92
|
+
"#{desc1}\nStandardError or RuntimeError exception not expected, "\
|
93
|
+
"but raised:",
|
89
94
|
"#{desc1}\nAn exception not expected, but raised:",
|
90
95
|
]
|
91
96
|
messages = test_run_results(:fail).map(&:message)
|
92
|
-
messages.each_with_index
|
97
|
+
messages.each_with_index do |msg, n|
|
98
|
+
assert_that(msg).matches(/^#{exp[n]}/)
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|