assert 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/assert.gemspec +0 -2
- data/lib/assert/assert_runner.rb +1 -1
- data/lib/assert/assertions.rb +1 -1
- data/lib/assert/config.rb +6 -1
- data/lib/assert/config_helpers.rb +75 -0
- data/lib/assert/context.rb +20 -14
- data/lib/assert/context/test_dsl.rb +17 -13
- data/lib/assert/{view/default_view.rb → default_view.rb} +9 -17
- data/lib/assert/factory.rb +2 -7
- data/lib/assert/file_line.rb +7 -3
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +1 -1
- data/lib/assert/result.rb +84 -90
- data/lib/assert/runner.rb +8 -2
- data/lib/assert/suite.rb +15 -5
- data/lib/assert/test.rb +112 -75
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +108 -21
- data/lib/assert/view_helpers.rb +238 -0
- data/test/support/factory.rb +23 -6
- data/test/system/test_tests.rb +359 -0
- data/test/unit/assertions_tests.rb +1 -1
- data/test/unit/config_helpers_tests.rb +95 -0
- data/test/unit/config_tests.rb +5 -1
- data/test/unit/context/test_dsl_tests.rb +25 -17
- data/test/unit/context_tests.rb +45 -10
- data/test/unit/factory_tests.rb +9 -11
- data/test/unit/file_line_tests.rb +22 -0
- data/test/unit/result_tests.rb +219 -160
- data/test/unit/runner_tests.rb +19 -5
- data/test/unit/suite_tests.rb +23 -4
- data/test/unit/test_tests.rb +167 -33
- data/test/unit/view_helpers_tests.rb +210 -0
- data/test/unit/view_tests.rb +66 -26
- metadata +12 -23
- data/lib/assert/view/base.rb +0 -91
- data/lib/assert/view/helpers/ansi_styles.rb +0 -25
- data/lib/assert/view/helpers/common.rb +0 -209
- data/test/system/running_tests.rb +0 -404
@@ -1,404 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
|
3
|
-
class RunningSystemTests < Assert::Context
|
4
|
-
desc "Running a test (with no halt-on-fail) that"
|
5
|
-
subject{ @test }
|
6
|
-
|
7
|
-
class NothingTests < RunningSystemTests
|
8
|
-
desc "does nothing"
|
9
|
-
setup do
|
10
|
-
@test = Factory.test
|
11
|
-
@test.run
|
12
|
-
end
|
13
|
-
|
14
|
-
should "have 0 results" do
|
15
|
-
assert_equal 0, subject.result_count
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
class PassTests < RunningSystemTests
|
21
|
-
desc "passes a single assertion"
|
22
|
-
setup do
|
23
|
-
@test = Factory.test{ assert(1 == 1) }
|
24
|
-
@test.run
|
25
|
-
end
|
26
|
-
|
27
|
-
should "have 1 result" do
|
28
|
-
assert_equal 1, subject.result_count
|
29
|
-
end
|
30
|
-
|
31
|
-
should "have 1 pass result" do
|
32
|
-
assert_equal 1, subject.result_count(:pass)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
class FailTests < RunningSystemTests
|
38
|
-
desc "fails a single assertion"
|
39
|
-
setup do
|
40
|
-
@test = Factory.test{ assert(1 == 0) }
|
41
|
-
@test.run
|
42
|
-
end
|
43
|
-
|
44
|
-
should "have 1 result" do
|
45
|
-
assert_equal 1, subject.result_count
|
46
|
-
end
|
47
|
-
|
48
|
-
should "have 1 fail result" do
|
49
|
-
assert_equal 1, subject.result_count(:fail)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
class SkipTests < RunningSystemTests
|
55
|
-
desc "skips once"
|
56
|
-
setup do
|
57
|
-
@test = Factory.test{ skip }
|
58
|
-
@test.run
|
59
|
-
end
|
60
|
-
|
61
|
-
should "have 1 result" do
|
62
|
-
assert_equal 1, subject.result_count
|
63
|
-
end
|
64
|
-
|
65
|
-
should "have 1 skip result" do
|
66
|
-
assert_equal 1, subject.result_count(:skip)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
class ErrorTests < RunningSystemTests
|
72
|
-
desc "errors once"
|
73
|
-
setup do
|
74
|
-
@test = Factory.test{ raise("WHAT") }
|
75
|
-
@test.run
|
76
|
-
end
|
77
|
-
|
78
|
-
should "have 1 result" do
|
79
|
-
assert_equal 1, subject.result_count
|
80
|
-
end
|
81
|
-
|
82
|
-
should "have 1 error result" do
|
83
|
-
assert_equal 1, subject.result_count(:error)
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
class MixedTests < RunningSystemTests
|
89
|
-
desc "has 1 pass and 1 fail assertion"
|
90
|
-
setup do
|
91
|
-
@test = Factory.test do
|
92
|
-
assert(1 == 1)
|
93
|
-
assert(1 == 0)
|
94
|
-
end
|
95
|
-
@test.run
|
96
|
-
end
|
97
|
-
|
98
|
-
should "have 2 total results" do
|
99
|
-
assert_equal 2, subject.result_count
|
100
|
-
end
|
101
|
-
|
102
|
-
should "have 1 pass result" do
|
103
|
-
assert_equal 1, subject.result_count(:pass)
|
104
|
-
end
|
105
|
-
|
106
|
-
should "have 1 fail result" do
|
107
|
-
assert_equal 1, subject.result_count(:fail)
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
class MixedSkipTests < RunningSystemTests
|
113
|
-
desc "has 1 pass and 1 fail assertion with a skip call in between"
|
114
|
-
setup do
|
115
|
-
@test = Factory.test do
|
116
|
-
assert(1 == 1)
|
117
|
-
skip
|
118
|
-
assert(1 == 0)
|
119
|
-
end
|
120
|
-
@test.run
|
121
|
-
end
|
122
|
-
|
123
|
-
should "have 2 total results" do
|
124
|
-
assert_equal 2, subject.result_count
|
125
|
-
end
|
126
|
-
|
127
|
-
should "have a skip for its last result" do
|
128
|
-
assert_kind_of Assert::Result::Skip, subject.results.last
|
129
|
-
end
|
130
|
-
|
131
|
-
should "have 1 pass result" do
|
132
|
-
assert_equal 1, subject.result_count(:pass)
|
133
|
-
end
|
134
|
-
|
135
|
-
should "have 1 skip result" do
|
136
|
-
assert_equal 1, subject.result_count(:skip)
|
137
|
-
end
|
138
|
-
|
139
|
-
should "have 0 fail results" do
|
140
|
-
assert_equal 0, subject.result_count(:fail)
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
class MixedErrorTests < RunningSystemTests
|
146
|
-
desc "has 1 pass and 1 fail assertion with an exception raised in between"
|
147
|
-
setup do
|
148
|
-
@test = Factory.test do
|
149
|
-
assert(1 == 1)
|
150
|
-
raise Exception, "something errored"
|
151
|
-
assert(1 == 0)
|
152
|
-
end
|
153
|
-
@test.run
|
154
|
-
end
|
155
|
-
|
156
|
-
should "have an error for its last result" do
|
157
|
-
assert_kind_of Assert::Result::Error, subject.results.last
|
158
|
-
end
|
159
|
-
|
160
|
-
should "have 2 total results" do
|
161
|
-
assert_equal 2, subject.result_count
|
162
|
-
end
|
163
|
-
|
164
|
-
should "have 1 pass result" do
|
165
|
-
assert_equal 1, subject.result_count(:pass)
|
166
|
-
end
|
167
|
-
|
168
|
-
should "have 1 error result" do
|
169
|
-
assert_equal 1, subject.result_count(:error)
|
170
|
-
end
|
171
|
-
|
172
|
-
should "have 0 fail results" do
|
173
|
-
assert_equal 0, subject.result_count(:fail)
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
class MixedPassTests < RunningSystemTests
|
179
|
-
desc "has 1 pass and 1 fail assertion with a pass call in between"
|
180
|
-
setup do
|
181
|
-
@test = Factory.test do
|
182
|
-
assert(1 == 1)
|
183
|
-
pass
|
184
|
-
assert(1 == 0)
|
185
|
-
end
|
186
|
-
@test.run
|
187
|
-
end
|
188
|
-
|
189
|
-
should "have a pass for its last result" do
|
190
|
-
assert_kind_of Assert::Result::Fail, subject.results.last
|
191
|
-
end
|
192
|
-
|
193
|
-
should "have 3 total results" do
|
194
|
-
assert_equal 3, subject.result_count
|
195
|
-
end
|
196
|
-
|
197
|
-
should "have 2 pass results" do
|
198
|
-
assert_equal 2, subject.result_count(:pass)
|
199
|
-
end
|
200
|
-
|
201
|
-
should "have 1 fail results" do
|
202
|
-
assert_equal 1, subject.result_count(:fail)
|
203
|
-
end
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
class MixedFailTests < RunningSystemTests
|
208
|
-
desc "has 1 pass and 1 fail assertion with a fail call in between"
|
209
|
-
setup do
|
210
|
-
@test = Factory.test do
|
211
|
-
assert(1 == 0)
|
212
|
-
fail
|
213
|
-
assert(1 == 1)
|
214
|
-
end
|
215
|
-
@test.run
|
216
|
-
end
|
217
|
-
|
218
|
-
should "have a fail for its last result" do
|
219
|
-
assert_kind_of Assert::Result::Pass, subject.results.last
|
220
|
-
end
|
221
|
-
|
222
|
-
should "have 3 total results" do
|
223
|
-
assert_equal 3, subject.result_count
|
224
|
-
end
|
225
|
-
|
226
|
-
should "have 1 pass results" do
|
227
|
-
assert_equal 1, subject.result_count(:pass)
|
228
|
-
end
|
229
|
-
|
230
|
-
should "have 2 fail results" do
|
231
|
-
assert_equal 2, subject.result_count(:fail)
|
232
|
-
end
|
233
|
-
|
234
|
-
end
|
235
|
-
|
236
|
-
class MixedFlunkTests < RunningSystemTests
|
237
|
-
desc "has 1 pass and 1 fail assertion with a flunk call in between"
|
238
|
-
setup do
|
239
|
-
@test = Factory.test do
|
240
|
-
assert(1 == 0)
|
241
|
-
flunk
|
242
|
-
assert(1 == 1)
|
243
|
-
end
|
244
|
-
@test.run
|
245
|
-
end
|
246
|
-
|
247
|
-
should "have a fail for its last result" do
|
248
|
-
assert_kind_of Assert::Result::Pass, subject.results.last
|
249
|
-
end
|
250
|
-
|
251
|
-
should "have 3 total results" do
|
252
|
-
assert_equal 3, subject.result_count
|
253
|
-
end
|
254
|
-
|
255
|
-
should "have 1 pass results" do
|
256
|
-
assert_equal 1, subject.result_count(:pass)
|
257
|
-
end
|
258
|
-
|
259
|
-
should "have 2 fail results" do
|
260
|
-
assert_equal 2, subject.result_count(:fail)
|
261
|
-
end
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
class WithSetupsTests < RunningSystemTests
|
266
|
-
desc "has tests that depend on setups"
|
267
|
-
setup do
|
268
|
-
assert_style_msg = @asm = "set by assert style setup"
|
269
|
-
testunit_style_msg = @tusm = "set by test/unit style setup"
|
270
|
-
@context_class = Factory.context_class do
|
271
|
-
# assert style setup
|
272
|
-
setup do
|
273
|
-
# get msgs into test scope
|
274
|
-
@assert_style_msg = assert_style_msg
|
275
|
-
@testunit_style_msg = testunit_style_msg
|
276
|
-
|
277
|
-
@setup_asm = @assert_style_msg
|
278
|
-
end
|
279
|
-
# classic test/unit style setup
|
280
|
-
def setup; @setup_tusm = @testunit_style_msg; end
|
281
|
-
end
|
282
|
-
@test = Factory.test("something", Factory.context_info(@context_class)) do
|
283
|
-
assert @assert_style_msg
|
284
|
-
assert @testunit_style_msg
|
285
|
-
|
286
|
-
@__running_test__.pass_results.first.
|
287
|
-
instance_variable_set("@message", @setup_asm)
|
288
|
-
|
289
|
-
@__running_test__.pass_results.last.
|
290
|
-
instance_variable_set("@message", @setup_tusm)
|
291
|
-
end
|
292
|
-
@test.run
|
293
|
-
end
|
294
|
-
|
295
|
-
should "have a passing result for each setup type" do
|
296
|
-
assert_equal 2, subject.result_count
|
297
|
-
assert_equal 2, subject.result_count(:pass)
|
298
|
-
end
|
299
|
-
|
300
|
-
should "have run the assert style setup" do
|
301
|
-
assert_equal @asm, subject.pass_results.first.message
|
302
|
-
end
|
303
|
-
|
304
|
-
should "have run the test/unit style setup" do
|
305
|
-
assert_equal @tusm, subject.pass_results.last.message
|
306
|
-
end
|
307
|
-
|
308
|
-
end
|
309
|
-
|
310
|
-
class WithTeardownsTests < RunningSystemTests
|
311
|
-
desc "has tests that depend on teardowns"
|
312
|
-
setup do
|
313
|
-
assert_style_msg = @asm = "set by assert style teardown"
|
314
|
-
testunit_style_msg = @tusm = "set by test/unit style teardown"
|
315
|
-
@context_class = Factory.context_class do
|
316
|
-
setup do
|
317
|
-
# get msgs into test scope
|
318
|
-
@assert_style_msg = assert_style_msg
|
319
|
-
@testunit_style_msg = testunit_style_msg
|
320
|
-
end
|
321
|
-
# assert style teardown
|
322
|
-
teardown do
|
323
|
-
@__running_test__.pass_results.first.
|
324
|
-
instance_variable_set("@message", @assert_style_msg)
|
325
|
-
end
|
326
|
-
# classic test/unit style teardown
|
327
|
-
def teardown
|
328
|
-
@__running_test__.pass_results.last.
|
329
|
-
instance_variable_set("@message", @testunit_style_msg)
|
330
|
-
end
|
331
|
-
end
|
332
|
-
@test = Factory.test("something amazing", Factory.context_info(@context_class)) do
|
333
|
-
assert(true) # first pass result
|
334
|
-
assert(true) # last pass result
|
335
|
-
end
|
336
|
-
@test.run
|
337
|
-
end
|
338
|
-
|
339
|
-
should "have a passing result for each teardown type" do
|
340
|
-
assert_equal 2, subject.result_count
|
341
|
-
assert_equal 2, subject.result_count(:pass)
|
342
|
-
end
|
343
|
-
|
344
|
-
should "have run the assert style teardown" do
|
345
|
-
assert_equal @asm, subject.pass_results.first.message
|
346
|
-
end
|
347
|
-
|
348
|
-
should "have run test/unit style teardown" do
|
349
|
-
assert_equal @tusm, subject.pass_results.last.message
|
350
|
-
end
|
351
|
-
|
352
|
-
end
|
353
|
-
|
354
|
-
class WithAroundsTests < RunningSystemTests
|
355
|
-
desc "has arounds (in addition to setups/teardowns)"
|
356
|
-
setup do
|
357
|
-
@parent_class = Factory.modes_off_context_class do
|
358
|
-
around do |block|
|
359
|
-
@__running_test__.output += "p-around start, "
|
360
|
-
block.call
|
361
|
-
@__running_test__.output += "p-around end."
|
362
|
-
end
|
363
|
-
setup{ @__running_test__.output += "p-setup, " }
|
364
|
-
teardown{ @__running_test__.output += "p-teardown, " }
|
365
|
-
end
|
366
|
-
|
367
|
-
@context_class = Factory.modes_off_context_class(@parent_class) do
|
368
|
-
attr_accessor :out_status
|
369
|
-
|
370
|
-
setup{ @__running_test__.output += "c-setup1, " }
|
371
|
-
around do |block|
|
372
|
-
@__running_test__.output += "c-around1 start, "
|
373
|
-
block.call
|
374
|
-
@__running_test__.output += "c-around1 end, "
|
375
|
-
end
|
376
|
-
teardown{ @__running_test__.output += "c-teardown1, " }
|
377
|
-
setup{ @__running_test__.output += "c-setup2, " }
|
378
|
-
around do |block|
|
379
|
-
@__running_test__.output += "c-around2 start, "
|
380
|
-
block.call
|
381
|
-
@__running_test__.output += "c-around2 end, "
|
382
|
-
end
|
383
|
-
teardown{ @__running_test__.output += "c-teardown2, " }
|
384
|
-
end
|
385
|
-
|
386
|
-
|
387
|
-
@test = Factory.test("something amazing", Factory.context_info(@context_class)) do
|
388
|
-
@__running_test__.output += "TEST, "
|
389
|
-
end
|
390
|
-
@test.run
|
391
|
-
end
|
392
|
-
|
393
|
-
should "run the arounds outside of the setups/teardowns/test" do
|
394
|
-
exp = "p-around start, c-around1 start, c-around2 start, "\
|
395
|
-
"p-setup, c-setup1, c-setup2, "\
|
396
|
-
"TEST, "\
|
397
|
-
"c-teardown1, c-teardown2, p-teardown, "\
|
398
|
-
"c-around2 end, c-around1 end, p-around end."
|
399
|
-
assert_equal exp, subject.output
|
400
|
-
end
|
401
|
-
|
402
|
-
end
|
403
|
-
|
404
|
-
end
|