assert 2.18.2 → 2.18.3

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