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