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