assert 2.18.2 → 2.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +7 -6
- data/assert.gemspec +5 -2
- data/bin/assert +1 -0
- data/lib/assert.rb +2 -0
- data/lib/assert/actual_value.rb +143 -0
- data/lib/assert/assert_runner.rb +2 -0
- data/lib/assert/assertions.rb +82 -20
- data/lib/assert/cli.rb +2 -0
- data/lib/assert/config.rb +2 -0
- data/lib/assert/config_helpers.rb +2 -0
- data/lib/assert/context.rb +33 -37
- data/lib/assert/context/let_dsl.rb +16 -0
- data/lib/assert/context/method_missing.rb +22 -0
- data/lib/assert/context/setup_dsl.rb +3 -0
- data/lib/assert/context/subject_dsl.rb +26 -24
- data/lib/assert/context/suite_dsl.rb +3 -0
- data/lib/assert/context/test_dsl.rb +3 -0
- data/lib/assert/context_info.rb +2 -0
- data/lib/assert/default_runner.rb +2 -0
- data/lib/assert/default_suite.rb +2 -0
- data/lib/assert/default_view.rb +2 -0
- data/lib/assert/factory.rb +2 -0
- data/lib/assert/file_line.rb +2 -0
- data/lib/assert/macro.rb +2 -0
- data/lib/assert/macros/methods.rb +6 -4
- data/lib/assert/result.rb +8 -1
- data/lib/assert/runner.rb +2 -0
- data/lib/assert/stub.rb +45 -0
- data/lib/assert/suite.rb +9 -10
- data/lib/assert/test.rb +3 -9
- data/lib/assert/utils.rb +3 -1
- data/lib/assert/version.rb +3 -1
- data/lib/assert/view.rb +2 -0
- data/lib/assert/view_helpers.rb +2 -0
- data/test/helper.rb +28 -28
- data/test/support/factory.rb +17 -0
- data/test/support/inherited_stuff.rb +2 -0
- data/test/system/stub_tests.rb +334 -333
- data/test/system/test_tests.rb +101 -109
- data/test/unit/actual_value_tests.rb +373 -0
- data/test/unit/assert_tests.rb +79 -61
- data/test/unit/assertions/assert_block_tests.rb +32 -31
- data/test/unit/assertions/assert_changes_tests.rb +99 -0
- data/test/unit/assertions/assert_empty_tests.rb +35 -32
- data/test/unit/assertions/assert_equal_tests.rb +96 -74
- data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
- data/test/unit/assertions/assert_includes_tests.rb +40 -37
- data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
- data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
- data/test/unit/assertions/assert_match_tests.rb +36 -33
- data/test/unit/assertions/assert_nil_tests.rb +32 -31
- data/test/unit/assertions/assert_raises_tests.rb +57 -55
- data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
- data/test/unit/assertions/assert_same_tests.rb +88 -81
- data/test/unit/assertions/assert_true_false_tests.rb +62 -60
- data/test/unit/assertions_tests.rb +28 -24
- data/test/unit/config_helpers_tests.rb +45 -38
- data/test/unit/config_tests.rb +40 -34
- data/test/unit/context/let_dsl_tests.rb +12 -0
- data/test/unit/context/setup_dsl_tests.rb +72 -81
- data/test/unit/context/subject_dsl_tests.rb +17 -43
- data/test/unit/context/suite_dsl_tests.rb +17 -16
- data/test/unit/context/test_dsl_tests.rb +52 -52
- data/test/unit/context_info_tests.rb +25 -15
- data/test/unit/context_tests.rb +186 -179
- data/test/unit/default_runner_tests.rb +4 -5
- data/test/unit/default_suite_tests.rb +59 -53
- data/test/unit/factory_tests.rb +7 -3
- data/test/unit/file_line_tests.rb +35 -35
- data/test/unit/macro_tests.rb +16 -10
- data/test/unit/result_tests.rb +161 -183
- data/test/unit/runner_tests.rb +67 -65
- data/test/unit/suite_tests.rb +58 -59
- data/test/unit/test_tests.rb +120 -139
- data/test/unit/utils_tests.rb +45 -45
- data/test/unit/view_helpers_tests.rb +56 -52
- data/test/unit/view_tests.rb +24 -23
- metadata +29 -6
data/test/system/test_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
|
3
5
|
class Assert::Test
|
@@ -6,332 +8,322 @@ class Assert::Test
|
|
6
8
|
include Assert::Test::TestHelpers
|
7
9
|
|
8
10
|
desc "Assert::Test"
|
9
|
-
|
11
|
+
|
12
|
+
setup do
|
13
|
+
subject.run(&test_run_callback)
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
class NoResultsTests < SystemTests
|
13
18
|
desc "when producing no results"
|
14
|
-
|
15
|
-
@test = Factory.test
|
16
|
-
@test.run(&test_run_callback)
|
17
|
-
end
|
19
|
+
subject { Factory.test }
|
18
20
|
|
19
21
|
should "generate 0 results" do
|
20
|
-
|
22
|
+
assert_that(test_run_result_count).equals(0)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
class PassTests < SystemTests
|
25
27
|
desc "when passing a single assertion"
|
26
|
-
|
27
|
-
@test = Factory.test{ assert(1 == 1) }
|
28
|
-
@test.run(&test_run_callback)
|
29
|
-
end
|
28
|
+
subject { Factory.test{ assert(1 == 1) } }
|
30
29
|
|
31
30
|
should "generate 1 result" do
|
32
|
-
|
31
|
+
assert_that(test_run_result_count).equals(1)
|
33
32
|
end
|
34
33
|
|
35
34
|
should "generate 1 pass result" do
|
36
|
-
|
35
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
class FailTests < SystemTests
|
41
40
|
desc "when failing a single assertion"
|
42
|
-
|
43
|
-
@test = Factory.test{ assert(1 == 0) }
|
44
|
-
@test.run(&test_run_callback)
|
45
|
-
end
|
41
|
+
subject { Factory.test{ assert(1 == 0) } }
|
46
42
|
|
47
43
|
should "generate 1 result" do
|
48
|
-
|
44
|
+
assert_that(test_run_result_count).equals(1)
|
49
45
|
end
|
50
46
|
|
51
47
|
should "generate 1 fail result" do
|
52
|
-
|
48
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
56
52
|
class SkipTests < SystemTests
|
57
53
|
desc "when skipping once"
|
58
|
-
|
59
|
-
@test = Factory.test{ skip }
|
60
|
-
@test.run(&test_run_callback)
|
61
|
-
end
|
54
|
+
subject { Factory.test{ skip } }
|
62
55
|
|
63
56
|
should "generate 1 result" do
|
64
|
-
|
57
|
+
assert_that(test_run_result_count).equals(1)
|
65
58
|
end
|
66
59
|
|
67
60
|
should "generate 1 skip result" do
|
68
|
-
|
61
|
+
assert_that(test_run_result_count(:skip)).equals(1)
|
69
62
|
end
|
70
63
|
end
|
71
64
|
|
72
65
|
class ErrorTests < SystemTests
|
73
66
|
desc "when erroring once"
|
74
|
-
|
75
|
-
@test = Factory.test{ raise("WHAT") }
|
76
|
-
@test.run(&test_run_callback)
|
77
|
-
end
|
67
|
+
subject { Factory.test{ raise("WHAT") } }
|
78
68
|
|
79
69
|
should "generate 1 result" do
|
80
|
-
|
70
|
+
assert_that(test_run_result_count).equals(1)
|
81
71
|
end
|
82
72
|
|
83
73
|
should "generate 1 error result" do
|
84
|
-
|
74
|
+
assert_that(test_run_result_count(:error)).equals(1)
|
85
75
|
end
|
86
76
|
end
|
87
77
|
|
88
78
|
class MixedTests < SystemTests
|
89
79
|
desc "when passing 1 assertion and failing 1 assertion"
|
90
|
-
|
91
|
-
|
80
|
+
subject {
|
81
|
+
Factory.test do
|
92
82
|
assert(1 == 1)
|
93
83
|
assert(1 == 0)
|
94
84
|
end
|
95
|
-
|
96
|
-
end
|
85
|
+
}
|
97
86
|
|
98
87
|
should "generate 2 total results" do
|
99
|
-
|
88
|
+
assert_that(test_run_result_count).equals(2)
|
100
89
|
end
|
101
90
|
|
102
91
|
should "generate 1 pass result" do
|
103
|
-
|
92
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
104
93
|
end
|
105
94
|
|
106
95
|
should "generate 1 fail result" do
|
107
|
-
|
96
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
108
97
|
end
|
109
98
|
end
|
110
99
|
|
111
100
|
class MixedSkipTests < SystemTests
|
112
101
|
desc "when passing 1 assertion and failing 1 assertion with a skip call in between"
|
113
|
-
|
114
|
-
|
102
|
+
subject {
|
103
|
+
Factory.test do
|
115
104
|
assert(1 == 1)
|
116
105
|
skip
|
117
106
|
assert(1 == 0)
|
118
107
|
end
|
119
|
-
|
120
|
-
end
|
108
|
+
}
|
121
109
|
|
122
110
|
should "generate 2 total results" do
|
123
|
-
|
111
|
+
assert_that(test_run_result_count).equals(2)
|
124
112
|
end
|
125
113
|
|
126
114
|
should "generate a skip for its last result" do
|
127
|
-
|
115
|
+
assert_that(last_test_run_result).is_kind_of(Assert::Result::Skip)
|
128
116
|
end
|
129
117
|
|
130
118
|
should "generate 1 pass result" do
|
131
|
-
|
119
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
132
120
|
end
|
133
121
|
|
134
122
|
should "generate 1 skip result" do
|
135
|
-
|
123
|
+
assert_that(test_run_result_count(:skip)).equals(1)
|
136
124
|
end
|
137
125
|
|
138
126
|
should "generate 0 fail results" do
|
139
|
-
|
127
|
+
assert_that(test_run_result_count(:fail)).equals(0)
|
140
128
|
end
|
141
129
|
end
|
142
130
|
|
143
131
|
class MixedErrorTests < SystemTests
|
144
132
|
desc "when passing 1 assertion and failing 1 assertion with an exception raised in between"
|
145
|
-
|
146
|
-
|
133
|
+
subject {
|
134
|
+
Factory.test do
|
147
135
|
assert(1 == 1)
|
148
136
|
raise Exception, "something errored"
|
149
137
|
assert(1 == 0)
|
150
138
|
end
|
151
|
-
|
152
|
-
end
|
139
|
+
}
|
153
140
|
|
154
141
|
should "generate 2 total results" do
|
155
|
-
|
142
|
+
assert_that(test_run_result_count).equals(2)
|
156
143
|
end
|
157
144
|
|
158
145
|
should "generate an error for its last result" do
|
159
|
-
|
146
|
+
assert_that(last_test_run_result).is_kind_of(Assert::Result::Error)
|
160
147
|
end
|
161
148
|
|
162
149
|
should "generate 1 pass result" do
|
163
|
-
|
150
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
164
151
|
end
|
165
152
|
|
166
153
|
should "generate 1 error result" do
|
167
|
-
|
154
|
+
assert_that(test_run_result_count(:error)).equals(1)
|
168
155
|
end
|
169
156
|
|
170
157
|
should "generate 0 fail results" do
|
171
|
-
|
158
|
+
assert_that(test_run_result_count(:fail)).equals(0)
|
172
159
|
end
|
173
160
|
end
|
174
161
|
|
175
162
|
class MixedPassTests < SystemTests
|
176
163
|
desc "when passing 1 assertion and failing 1 assertion with a pass call in between"
|
177
|
-
|
178
|
-
|
164
|
+
subject {
|
165
|
+
Factory.test do
|
179
166
|
assert(1 == 1)
|
180
167
|
pass
|
181
168
|
assert(1 == 0)
|
182
169
|
end
|
183
|
-
|
184
|
-
end
|
170
|
+
}
|
185
171
|
|
186
172
|
should "generate 3 total results" do
|
187
|
-
|
173
|
+
assert_that(test_run_result_count).equals(3)
|
188
174
|
end
|
189
175
|
|
190
176
|
should "generate a fail for its last result" do
|
191
|
-
|
177
|
+
assert_that(last_test_run_result).is_kind_of(Assert::Result::Fail)
|
192
178
|
end
|
193
179
|
|
194
180
|
should "generate 2 pass results" do
|
195
|
-
|
181
|
+
assert_that(test_run_result_count(:pass)).equals(2)
|
196
182
|
end
|
197
183
|
|
198
184
|
should "generate 1 fail result" do
|
199
|
-
|
185
|
+
assert_that(test_run_result_count(:fail)).equals(1)
|
200
186
|
end
|
201
187
|
end
|
202
188
|
|
203
189
|
class MixedFailTests < SystemTests
|
204
190
|
desc "when failing 1 assertion and passing 1 assertion with a fail call in between"
|
205
|
-
|
206
|
-
|
191
|
+
subject {
|
192
|
+
Factory.test do
|
207
193
|
assert(1 == 0)
|
208
194
|
fail
|
209
195
|
assert(1 == 1)
|
210
196
|
end
|
211
|
-
|
212
|
-
end
|
197
|
+
}
|
213
198
|
|
214
199
|
should "generate 3 total results" do
|
215
|
-
|
200
|
+
assert_that(test_run_result_count).equals(3)
|
216
201
|
end
|
217
202
|
|
218
203
|
should "generate a pass for its last result" do
|
219
|
-
|
204
|
+
assert_that(last_test_run_result).is_kind_of(Assert::Result::Pass)
|
220
205
|
end
|
221
206
|
|
222
207
|
should "generate 1 pass result" do
|
223
|
-
|
208
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
224
209
|
end
|
225
210
|
|
226
211
|
should "generate 2 fail results" do
|
227
|
-
|
212
|
+
assert_that(test_run_result_count(:fail)).equals(2)
|
228
213
|
end
|
229
214
|
end
|
230
215
|
|
231
216
|
class MixedFlunkTests < SystemTests
|
232
217
|
desc "has failing 1 assertion and passing 1 assertion with a flunk call in between"
|
233
|
-
|
234
|
-
|
218
|
+
subject {
|
219
|
+
Factory.test do
|
235
220
|
assert(1 == 0)
|
236
221
|
flunk
|
237
222
|
assert(1 == 1)
|
238
223
|
end
|
239
|
-
|
240
|
-
end
|
224
|
+
}
|
241
225
|
|
242
226
|
should "generate 3 total results" do
|
243
|
-
|
227
|
+
assert_that(test_run_result_count).equals(3)
|
244
228
|
end
|
245
229
|
|
246
230
|
should "generate a pass for its last result" do
|
247
|
-
|
231
|
+
assert_that(last_test_run_result).is_kind_of(Assert::Result::Pass)
|
248
232
|
end
|
249
233
|
|
250
234
|
should "generate 1 pass results" do
|
251
|
-
|
235
|
+
assert_that(test_run_result_count(:pass)).equals(1)
|
252
236
|
end
|
253
237
|
|
254
238
|
should "generate 2 fail results" do
|
255
|
-
|
239
|
+
assert_that(test_run_result_count(:fail)).equals(2)
|
256
240
|
end
|
257
241
|
end
|
258
242
|
|
259
243
|
class WithSetupsTests < SystemTests
|
260
244
|
desc "that has setup logic"
|
261
|
-
|
262
|
-
|
245
|
+
subject {
|
246
|
+
Factory.test("t", Factory.context_info(context_class1)) { pass "TEST" }
|
247
|
+
}
|
248
|
+
|
249
|
+
let(:context_class1) {
|
250
|
+
Factory.context_class do
|
263
251
|
# assert style
|
264
|
-
setup{ pass "assert style setup" }
|
252
|
+
setup { pass "assert style setup" }
|
265
253
|
# test/unit style
|
266
254
|
def setup; pass "test/unit style setup"; end
|
267
255
|
end
|
268
|
-
|
269
|
-
@test.run(&test_run_callback)
|
270
|
-
end
|
256
|
+
}
|
271
257
|
|
272
258
|
should "execute all setup logic when run" do
|
273
|
-
|
259
|
+
assert_that(test_run_result_count(:pass)).equals(3)
|
274
260
|
|
275
261
|
exp = ["assert style setup", "test/unit style setup", "TEST"]
|
276
|
-
|
262
|
+
assert_that(test_run_result_messages).equals(exp)
|
277
263
|
end
|
278
264
|
end
|
279
265
|
|
280
266
|
class WithTeardownsTests < SystemTests
|
281
267
|
desc "that has teardown logic"
|
282
|
-
|
283
|
-
|
268
|
+
subject {
|
269
|
+
Factory.test("t", Factory.context_info(context_class1)) { pass "TEST" }
|
270
|
+
}
|
271
|
+
|
272
|
+
let(:context_class1) {
|
273
|
+
Factory.context_class do
|
284
274
|
# assert style
|
285
|
-
teardown{ pass "assert style teardown" }
|
275
|
+
teardown { pass "assert style teardown" }
|
286
276
|
# test/unit style
|
287
277
|
def teardown; pass "test/unit style teardown"; end
|
288
278
|
end
|
289
|
-
|
290
|
-
@test.run(&test_run_callback)
|
291
|
-
end
|
279
|
+
}
|
292
280
|
|
293
281
|
should "execute all teardown logic when run" do
|
294
|
-
|
282
|
+
assert_that(test_run_result_count(:pass)).equals(3)
|
295
283
|
|
296
284
|
exp = ["TEST", "assert style teardown", "test/unit style teardown"]
|
297
|
-
|
285
|
+
assert_that(test_run_result_messages).equals(exp)
|
298
286
|
end
|
299
287
|
end
|
300
288
|
|
301
289
|
class WithAroundsTests < SystemTests
|
302
290
|
desc "that has around logic (in addition to setups/teardowns)"
|
303
|
-
|
304
|
-
|
291
|
+
subject {
|
292
|
+
Factory.test("t", Factory.context_info(context_class1)) { pass "TEST" }
|
293
|
+
}
|
294
|
+
|
295
|
+
let(:parent_context_class1) {
|
296
|
+
Factory.modes_off_context_class do
|
305
297
|
around do |block|
|
306
298
|
pass "parent around start"
|
307
299
|
block.call
|
308
300
|
pass "parent around end"
|
309
301
|
end
|
310
|
-
setup{ pass "parent setup" }
|
311
|
-
teardown{ pass "parent teardown" }
|
302
|
+
setup { pass "parent setup" }
|
303
|
+
teardown { pass "parent teardown" }
|
312
304
|
end
|
313
|
-
|
314
|
-
|
305
|
+
}
|
306
|
+
let(:context_class1) {
|
307
|
+
Factory.modes_off_context_class(parent_context_class1) do
|
308
|
+
setup { pass "child setup1" }
|
315
309
|
around do |block|
|
316
310
|
pass "child around1 start"
|
317
311
|
block.call
|
318
312
|
pass "child around1 end"
|
319
313
|
end
|
320
|
-
teardown{ pass "child teardown1" }
|
321
|
-
setup{ pass "child setup2" }
|
314
|
+
teardown { pass "child teardown1" }
|
315
|
+
setup { pass "child setup2" }
|
322
316
|
around do |block|
|
323
317
|
pass "child around2 start"
|
324
318
|
block.call
|
325
319
|
pass "child around2 end"
|
326
320
|
end
|
327
|
-
teardown{ pass "child teardown2" }
|
321
|
+
teardown { pass "child teardown2" }
|
328
322
|
end
|
329
|
-
|
330
|
-
@test.run(&test_run_callback)
|
331
|
-
end
|
323
|
+
}
|
332
324
|
|
333
325
|
should "run the arounds outside of the setups/teardowns/test" do
|
334
|
-
|
326
|
+
assert_that(test_run_result_count(:pass)).equals(13)
|
335
327
|
|
336
328
|
exp = [
|
337
329
|
"parent around start", "child around1 start", "child around2 start",
|
@@ -339,7 +331,7 @@ class Assert::Test
|
|
339
331
|
"child teardown1", "child teardown2", "parent teardown",
|
340
332
|
"child around2 end", "child around1 end", "parent around end"
|
341
333
|
]
|
342
|
-
|
334
|
+
assert_that(test_run_result_messages).equals(exp)
|
343
335
|
end
|
344
336
|
end
|
345
337
|
end
|
@@ -0,0 +1,373 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "assert"
|
4
|
+
require "assert/actual_value"
|
5
|
+
|
6
|
+
class Assert::ActualValue
|
7
|
+
class UnitTests < Assert::Context
|
8
|
+
desc "Assert::ActualValue"
|
9
|
+
subject { unit_class }
|
10
|
+
|
11
|
+
let(:unit_class) { Assert::ActualValue }
|
12
|
+
end
|
13
|
+
|
14
|
+
class InitTests < UnitTests
|
15
|
+
desc "when init"
|
16
|
+
subject { unit_class.new(actual_value1, context: context1) }
|
17
|
+
|
18
|
+
let(:actual_value1) { Factory.string }
|
19
|
+
let(:context1) { Factory.modes_off_context }
|
20
|
+
|
21
|
+
should have_imeths :returns_true, :does_not_return_true
|
22
|
+
should have_imeths :raises, :does_not_raise
|
23
|
+
should have_imeths :changes, :does_not_change
|
24
|
+
should have_imeths :is_a_kind_of, :is_not_a_kind_of
|
25
|
+
should have_imeths :is_kind_of, :is_not_kind_of
|
26
|
+
should have_imeths :is_an_instance_of, :is_not_an_instance_of
|
27
|
+
should have_imeths :is_instance_of, :is_not_instance_of
|
28
|
+
should have_imeths :responds_to, :does_not_respond_to
|
29
|
+
should have_imeths :is_the_same_as, :is_not_the_same_as
|
30
|
+
should have_imeths :is, :is_not
|
31
|
+
should have_imeths :equals, :does_not_equal
|
32
|
+
should have_imeths :is_equal_to, :is_not_equal_to
|
33
|
+
should have_imeths :matches, :does_not_match
|
34
|
+
should have_imeths :is_empty, :is_not_empty
|
35
|
+
should have_imeths :includes, :does_not_include
|
36
|
+
should have_imeths :is_nil, :is_not_nil
|
37
|
+
should have_imeths :is_true, :is_not_true
|
38
|
+
should have_imeths :is_false, :is_not_false
|
39
|
+
should have_imeths :is_a_file, :is_not_a_file
|
40
|
+
end
|
41
|
+
|
42
|
+
class MethodsTests < InitTests
|
43
|
+
desc "methods"
|
44
|
+
|
45
|
+
let(:args1) { Factory.integer(3).times.map { Factory.string } }
|
46
|
+
let(:capture_last_call_block) { ->(call) { @last_call = call } }
|
47
|
+
|
48
|
+
should "call to their equivalent context methods" do
|
49
|
+
assert_calls(
|
50
|
+
:assert_block,
|
51
|
+
when_calling: :returns_true,
|
52
|
+
on_value: -> {}
|
53
|
+
) do |value, call|
|
54
|
+
assert_equal args1, call.args
|
55
|
+
assert_equal value, call.block
|
56
|
+
end
|
57
|
+
|
58
|
+
assert_calls(
|
59
|
+
:assert_not_block,
|
60
|
+
when_calling: :does_not_return_true,
|
61
|
+
on_value: -> {}
|
62
|
+
) do |value, call|
|
63
|
+
assert_equal args1, call.args
|
64
|
+
assert_equal value, call.block
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_calls(
|
68
|
+
:assert_raises,
|
69
|
+
when_calling: :raises,
|
70
|
+
on_value: -> {}
|
71
|
+
) do |value, call|
|
72
|
+
assert_equal args1, call.args
|
73
|
+
assert_equal value, call.block
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_calls(
|
77
|
+
:assert_nothing_raised,
|
78
|
+
when_calling: :does_not_raise,
|
79
|
+
on_value: -> {}
|
80
|
+
) do |value, call|
|
81
|
+
assert_equal args1, call.args
|
82
|
+
assert_equal value, call.block
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_calls(
|
86
|
+
:assert_changes,
|
87
|
+
when_calling: :changes,
|
88
|
+
on_value: -> {}
|
89
|
+
) do |value, call|
|
90
|
+
assert_equal args1, call.args
|
91
|
+
assert_equal value, call.block
|
92
|
+
end
|
93
|
+
|
94
|
+
assert_calls(
|
95
|
+
:assert_not_changes,
|
96
|
+
when_calling: :does_not_change,
|
97
|
+
on_value: -> {}
|
98
|
+
) do |value, call|
|
99
|
+
assert_equal args1, call.args
|
100
|
+
assert_equal value, call.block
|
101
|
+
end
|
102
|
+
|
103
|
+
assert_calls(
|
104
|
+
:assert_kind_of,
|
105
|
+
when_calling: [:is_a_kind_of, String],
|
106
|
+
on_value: actual_value1
|
107
|
+
) do |value, call|
|
108
|
+
assert_equal [String, value, *args1], call.args
|
109
|
+
end
|
110
|
+
|
111
|
+
assert_calls(
|
112
|
+
:assert_kind_of,
|
113
|
+
when_calling: [:is_kind_of, String],
|
114
|
+
on_value: actual_value1
|
115
|
+
) do |value, call|
|
116
|
+
assert_equal [String, value, *args1], call.args
|
117
|
+
end
|
118
|
+
|
119
|
+
assert_calls(
|
120
|
+
:assert_not_kind_of,
|
121
|
+
when_calling: [:is_not_a_kind_of, String],
|
122
|
+
on_value: actual_value1
|
123
|
+
) do |value, call|
|
124
|
+
assert_equal [String, value, *args1], call.args
|
125
|
+
end
|
126
|
+
|
127
|
+
assert_calls(
|
128
|
+
:assert_not_kind_of,
|
129
|
+
when_calling: [:is_not_kind_of, String],
|
130
|
+
on_value: actual_value1
|
131
|
+
) do |value, call|
|
132
|
+
assert_equal [String, value, *args1], call.args
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_calls(
|
136
|
+
:assert_instance_of,
|
137
|
+
when_calling: [:is_an_instance_of, String],
|
138
|
+
on_value: actual_value1
|
139
|
+
) do |value, call|
|
140
|
+
assert_equal [String, value, *args1], call.args
|
141
|
+
end
|
142
|
+
|
143
|
+
assert_calls(
|
144
|
+
:assert_instance_of,
|
145
|
+
when_calling: [:is_instance_of, String],
|
146
|
+
on_value: actual_value1
|
147
|
+
) do |value, call|
|
148
|
+
assert_equal [String, value, *args1], call.args
|
149
|
+
end
|
150
|
+
|
151
|
+
assert_calls(
|
152
|
+
:assert_not_instance_of,
|
153
|
+
when_calling: [:is_not_an_instance_of, String],
|
154
|
+
on_value: actual_value1
|
155
|
+
) do |value, call|
|
156
|
+
assert_equal [String, value, *args1], call.args
|
157
|
+
end
|
158
|
+
|
159
|
+
assert_calls(
|
160
|
+
:assert_not_instance_of,
|
161
|
+
when_calling: [:is_not_instance_of, String],
|
162
|
+
on_value: actual_value1
|
163
|
+
) do |value, call|
|
164
|
+
assert_equal [String, value, *args1], call.args
|
165
|
+
end
|
166
|
+
|
167
|
+
assert_calls(
|
168
|
+
:assert_responds_to,
|
169
|
+
when_calling: [:responds_to, :method],
|
170
|
+
on_value: actual_value1
|
171
|
+
) do |value, call|
|
172
|
+
assert_equal [:method, value, *args1], call.args
|
173
|
+
end
|
174
|
+
|
175
|
+
assert_calls(
|
176
|
+
:assert_not_responds_to,
|
177
|
+
when_calling: [:does_not_respond_to, :method],
|
178
|
+
on_value: actual_value1
|
179
|
+
) do |value, call|
|
180
|
+
assert_equal [:method, value, *args1], call.args
|
181
|
+
end
|
182
|
+
|
183
|
+
assert_calls(
|
184
|
+
:assert_same,
|
185
|
+
when_calling: [:is_the_same_as, "something"],
|
186
|
+
on_value: actual_value1
|
187
|
+
) do |value, call|
|
188
|
+
assert_equal ["something", value, *args1], call.args
|
189
|
+
end
|
190
|
+
|
191
|
+
assert_calls(
|
192
|
+
:assert_same,
|
193
|
+
when_calling: [:is, "something"],
|
194
|
+
on_value: actual_value1
|
195
|
+
) do |value, call|
|
196
|
+
assert_equal ["something", value, *args1], call.args
|
197
|
+
end
|
198
|
+
|
199
|
+
assert_calls(
|
200
|
+
:assert_not_same,
|
201
|
+
when_calling: [:is_not_the_same_as, "something"],
|
202
|
+
on_value: actual_value1
|
203
|
+
) do |value, call|
|
204
|
+
assert_equal ["something", value, *args1], call.args
|
205
|
+
end
|
206
|
+
|
207
|
+
assert_calls(
|
208
|
+
:assert_not_same,
|
209
|
+
when_calling: [:is_not, "something"],
|
210
|
+
on_value: actual_value1
|
211
|
+
) do |value, call|
|
212
|
+
assert_equal ["something", value, *args1], call.args
|
213
|
+
end
|
214
|
+
|
215
|
+
assert_calls(
|
216
|
+
:assert_equal,
|
217
|
+
when_calling: [:equals, "something"],
|
218
|
+
on_value: actual_value1
|
219
|
+
) do |value, call|
|
220
|
+
assert_equal ["something", value, *args1], call.args
|
221
|
+
end
|
222
|
+
|
223
|
+
assert_calls(
|
224
|
+
:assert_equal,
|
225
|
+
when_calling: [:is_equal_to, "something"],
|
226
|
+
on_value: actual_value1
|
227
|
+
) do |value, call|
|
228
|
+
assert_equal ["something", value, *args1], call.args
|
229
|
+
end
|
230
|
+
|
231
|
+
assert_calls(
|
232
|
+
:assert_not_equal,
|
233
|
+
when_calling: [:does_not_equal, "something"],
|
234
|
+
on_value: actual_value1
|
235
|
+
) do |value, call|
|
236
|
+
assert_equal ["something", value, *args1], call.args
|
237
|
+
end
|
238
|
+
|
239
|
+
assert_calls(
|
240
|
+
:assert_not_equal,
|
241
|
+
when_calling: [:is_not_equal_to, "something"],
|
242
|
+
on_value: actual_value1
|
243
|
+
) do |value, call|
|
244
|
+
assert_equal ["something", value, *args1], call.args
|
245
|
+
end
|
246
|
+
|
247
|
+
assert_calls(
|
248
|
+
:assert_match,
|
249
|
+
when_calling: [:matches, "something"],
|
250
|
+
on_value: actual_value1
|
251
|
+
) do |value, call|
|
252
|
+
assert_equal ["something", value, *args1], call.args
|
253
|
+
end
|
254
|
+
|
255
|
+
assert_calls(
|
256
|
+
:assert_not_match,
|
257
|
+
when_calling: [:does_not_match, "something"],
|
258
|
+
on_value: actual_value1
|
259
|
+
) do |value, call|
|
260
|
+
assert_equal ["something", value, *args1], call.args
|
261
|
+
end
|
262
|
+
|
263
|
+
assert_calls(
|
264
|
+
:assert_empty,
|
265
|
+
when_calling: :is_empty,
|
266
|
+
on_value: actual_value1
|
267
|
+
) do |value, call|
|
268
|
+
assert_equal [value, *args1], call.args
|
269
|
+
end
|
270
|
+
|
271
|
+
assert_calls(
|
272
|
+
:assert_not_empty,
|
273
|
+
when_calling: :is_not_empty,
|
274
|
+
on_value: actual_value1
|
275
|
+
) do |value, call|
|
276
|
+
assert_equal [value, *args1], call.args
|
277
|
+
end
|
278
|
+
|
279
|
+
assert_calls(
|
280
|
+
:assert_includes,
|
281
|
+
when_calling: [:includes, "something"],
|
282
|
+
on_value: actual_value1
|
283
|
+
) do |value, call|
|
284
|
+
assert_equal ["something", value, *args1], call.args
|
285
|
+
end
|
286
|
+
|
287
|
+
assert_calls(
|
288
|
+
:assert_not_includes,
|
289
|
+
when_calling: [:does_not_include, "something"],
|
290
|
+
on_value: actual_value1
|
291
|
+
) do |value, call|
|
292
|
+
assert_equal ["something", value, *args1], call.args
|
293
|
+
end
|
294
|
+
|
295
|
+
assert_calls(
|
296
|
+
:assert_nil,
|
297
|
+
when_calling: :is_nil,
|
298
|
+
on_value: actual_value1
|
299
|
+
) do |value, call|
|
300
|
+
assert_equal [value, *args1], call.args
|
301
|
+
end
|
302
|
+
|
303
|
+
assert_calls(
|
304
|
+
:assert_not_nil,
|
305
|
+
when_calling: :is_not_nil,
|
306
|
+
on_value: actual_value1
|
307
|
+
) do |value, call|
|
308
|
+
assert_equal [value, *args1], call.args
|
309
|
+
end
|
310
|
+
|
311
|
+
assert_calls(
|
312
|
+
:assert_true,
|
313
|
+
when_calling: :is_true,
|
314
|
+
on_value: actual_value1
|
315
|
+
) do |value, call|
|
316
|
+
assert_equal [value, *args1], call.args
|
317
|
+
end
|
318
|
+
|
319
|
+
assert_calls(
|
320
|
+
:assert_not_true,
|
321
|
+
when_calling: :is_not_true,
|
322
|
+
on_value: actual_value1
|
323
|
+
) do |value, call|
|
324
|
+
assert_equal [value, *args1], call.args
|
325
|
+
end
|
326
|
+
|
327
|
+
assert_calls(
|
328
|
+
:assert_false,
|
329
|
+
when_calling: :is_false,
|
330
|
+
on_value: actual_value1
|
331
|
+
) do |value, call|
|
332
|
+
assert_equal [value, *args1], call.args
|
333
|
+
end
|
334
|
+
|
335
|
+
assert_calls(
|
336
|
+
:assert_not_false,
|
337
|
+
when_calling: :is_not_false,
|
338
|
+
on_value: actual_value1
|
339
|
+
) do |value, call|
|
340
|
+
assert_equal [value, *args1], call.args
|
341
|
+
end
|
342
|
+
|
343
|
+
assert_calls(
|
344
|
+
:assert_file_exists,
|
345
|
+
when_calling: :is_a_file,
|
346
|
+
on_value: actual_value1
|
347
|
+
) do |value, call|
|
348
|
+
assert_equal [value, *args1], call.args
|
349
|
+
end
|
350
|
+
|
351
|
+
assert_calls(
|
352
|
+
:assert_not_file_exists,
|
353
|
+
when_calling: :is_not_a_file,
|
354
|
+
on_value: actual_value1
|
355
|
+
) do |value, call|
|
356
|
+
assert_equal [value, *args1], call.args
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
private
|
361
|
+
|
362
|
+
def assert_calls(context_method, when_calling:, on_value:)
|
363
|
+
@last_call = nil
|
364
|
+
Assert.stub_on_call(context1, context_method, &capture_last_call_block)
|
365
|
+
|
366
|
+
unit_class.new(on_value, context: context1).public_send(*[*when_calling, *args1])
|
367
|
+
yield(on_value, @last_call)
|
368
|
+
|
369
|
+
Assert.unstub(context1, context_method)
|
370
|
+
@last_call = nil
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|