assert 2.18.0 → 2.19.0

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