fun_with_testing 0.0.4 → 0.0.10
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 +5 -13
- data/CHANGELOG.markdown +38 -0
- data/Gemfile +33 -11
- data/README.rdoc +3 -6
- data/Rakefile +38 -17
- data/VERSION +1 -1
- data/lib/fun_with/testing/assertions/basics.rb +250 -138
- data/lib/fun_with/testing/assertions_test_case.rb +67 -0
- data/lib/fun_with/testing/assertions_test_mocker.rb +15 -0
- data/lib/fun_with/testing/test_case.rb +1 -71
- data/lib/fun_with/testing/test_case_extensions.rb +47 -0
- data/lib/fun_with/testing/verbosity_methods.rb +33 -0
- data/lib/fun_with_testing.rb +16 -18
- data/test/helper.rb +3 -37
- data/test/test_assertions.rb +609 -14
- data/test/test_fun_with_testing.rb +3 -7
- data/test/test_verbosity.rb +2 -1
- metadata +19 -134
- data/lib/fun_with/testing/assertions/active_record.rb +0 -108
- data/lib/fun_with/testing/assertions/fun_with_files.rb +0 -109
- data/test/test_test_mode.rb +0 -28
data/test/test_assertions.rb
CHANGED
|
@@ -2,31 +2,626 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
module FunWith
|
|
4
4
|
module Testing
|
|
5
|
-
class TestAssertions <
|
|
6
|
-
|
|
5
|
+
class TestAssertions < AssertionsTestCase
|
|
6
|
+
def modded_object( &block )
|
|
7
|
+
m = Module.new(&block)
|
|
8
|
+
o = Object.new
|
|
9
|
+
o.extend( m )
|
|
10
|
+
o
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
debugger unless self.respond_to?(:context)
|
|
14
|
+
|
|
15
|
+
context "testing assertions" do
|
|
7
16
|
setup do
|
|
8
|
-
extended_test_case
|
|
17
|
+
extended_test_case # sets @case, which is used to access to assertions
|
|
18
|
+
@case_class.install_basic_assertions # send( :include, FunWith::Testing::Assertions::Basics )
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "testing :assert_zero()" do
|
|
22
|
+
should "accept only zeroes, reject all others" do
|
|
23
|
+
testing_method :assert_zero do
|
|
24
|
+
yep 0
|
|
25
|
+
yep 0.0
|
|
26
|
+
|
|
27
|
+
nope 1
|
|
28
|
+
nope :potato
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
testing_method :refute_zero do
|
|
32
|
+
yep 1
|
|
33
|
+
yep 0.4
|
|
34
|
+
yep( -1 )
|
|
35
|
+
yep :zero
|
|
36
|
+
yep "0"
|
|
37
|
+
yep "zero"
|
|
38
|
+
yep ""
|
|
39
|
+
|
|
40
|
+
nope 0
|
|
41
|
+
nope "0".to_i
|
|
42
|
+
nope "0".to_f
|
|
43
|
+
end
|
|
44
|
+
end
|
|
9
45
|
end
|
|
10
46
|
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
|
|
48
|
+
context "testing :assert_not_zero()" do
|
|
49
|
+
should "look for non-zeros everywhere" do
|
|
50
|
+
testing_method :assert_not_zero do
|
|
51
|
+
yep 1
|
|
52
|
+
yep( -1 )
|
|
53
|
+
yep 0.01
|
|
54
|
+
yep( -0.01 )
|
|
55
|
+
yep :zero
|
|
56
|
+
yep []
|
|
57
|
+
yep( {} )
|
|
58
|
+
yep ""
|
|
59
|
+
yep nil
|
|
60
|
+
nope 0
|
|
61
|
+
end
|
|
62
|
+
end
|
|
13
63
|
end
|
|
14
64
|
|
|
15
|
-
|
|
16
|
-
|
|
65
|
+
context "testing :assert_one()" do
|
|
66
|
+
should "pass all tests" do
|
|
67
|
+
testing_method :assert_one do
|
|
68
|
+
yep 1
|
|
69
|
+
yep 1.0
|
|
70
|
+
yep 1.to_c # comparison as a complex number
|
|
71
|
+
nope 2
|
|
72
|
+
nope( -3 )
|
|
73
|
+
nope []
|
|
74
|
+
nope( {} )
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "testing :refute_one()" do
|
|
80
|
+
should "pass all tests" do
|
|
81
|
+
testing_method :refute_one do
|
|
82
|
+
yep 2
|
|
83
|
+
yep( -3 )
|
|
84
|
+
yep []
|
|
85
|
+
yep( {} )
|
|
86
|
+
nope 1
|
|
87
|
+
nope 1.0
|
|
88
|
+
nope 1.to_c # comparison as a complex number
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "testing :assert_positive()" do
|
|
94
|
+
should "pass all tests" do
|
|
95
|
+
testing_method :assert_positive do
|
|
96
|
+
yep 1
|
|
97
|
+
yep 1000
|
|
98
|
+
yep 1000.0
|
|
99
|
+
yep 0.0000000000001
|
|
100
|
+
yep 5
|
|
101
|
+
yep 4
|
|
102
|
+
yep 0.00001
|
|
103
|
+
yep Math::PI
|
|
104
|
+
yep 1337
|
|
105
|
+
yep 91
|
|
106
|
+
|
|
107
|
+
nope 0
|
|
108
|
+
nope( -0.00001 )
|
|
109
|
+
nope( -50 )
|
|
110
|
+
nope( -5000 )
|
|
111
|
+
nope( -50000 )
|
|
112
|
+
nope 0
|
|
113
|
+
nope( -0.000000000001 )
|
|
114
|
+
nope( -1 )
|
|
115
|
+
nope( -1000 )
|
|
116
|
+
nope( -1000000 )
|
|
117
|
+
|
|
118
|
+
oops true
|
|
119
|
+
oops false
|
|
120
|
+
oops 10000.to_c
|
|
121
|
+
oops "3"
|
|
122
|
+
oops( {} )
|
|
123
|
+
oops []
|
|
124
|
+
oops :symbol
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
context "testing :refute_positive()" do
|
|
130
|
+
should "pass all tests" do
|
|
131
|
+
testing_method :refute_positive do
|
|
132
|
+
yep 0
|
|
133
|
+
yep 0.0
|
|
134
|
+
yep( -1 )
|
|
135
|
+
yep( -100 )
|
|
136
|
+
yep( -0.000000000001 )
|
|
137
|
+
yep( -1 )
|
|
138
|
+
yep( -1000 )
|
|
139
|
+
yep( -1000000 )
|
|
140
|
+
|
|
141
|
+
nope 1
|
|
142
|
+
nope 1000
|
|
143
|
+
nope 1000.0
|
|
144
|
+
nope 0.0000000000001
|
|
145
|
+
nope 0.0001
|
|
146
|
+
nope 1
|
|
147
|
+
nope 5
|
|
148
|
+
nope 99999999999999
|
|
149
|
+
|
|
150
|
+
oops []
|
|
151
|
+
oops nil
|
|
152
|
+
oops 5.to_c
|
|
153
|
+
oops 10000.to_c
|
|
154
|
+
oops true
|
|
155
|
+
oops false
|
|
156
|
+
end
|
|
157
|
+
end
|
|
17
158
|
end
|
|
18
159
|
|
|
19
|
-
|
|
20
|
-
|
|
160
|
+
context "testing :assert_true()" do
|
|
161
|
+
should "pass all tests" do
|
|
162
|
+
testing_method :assert_true do
|
|
163
|
+
yep true
|
|
164
|
+
|
|
165
|
+
nope false
|
|
166
|
+
nope nil
|
|
167
|
+
nope 5
|
|
168
|
+
nope "string"
|
|
169
|
+
nope :symbol
|
|
170
|
+
nope []
|
|
171
|
+
nope Hash.new
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
context "testing :assert_false()" do
|
|
177
|
+
should "pass all tests" do
|
|
178
|
+
testing_method :assert_false do
|
|
179
|
+
yep false
|
|
180
|
+
|
|
181
|
+
nope true
|
|
182
|
+
nope nil
|
|
183
|
+
nope 5
|
|
184
|
+
nope "string"
|
|
185
|
+
nope :symbol
|
|
186
|
+
nope []
|
|
187
|
+
nope Hash.new
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
context "testing :refute_true()" do
|
|
193
|
+
should "pass all tests" do
|
|
194
|
+
testing_method :refute_true do
|
|
195
|
+
yep false
|
|
196
|
+
yep nil
|
|
197
|
+
yep 5
|
|
198
|
+
yep "string"
|
|
199
|
+
yep :symbol
|
|
200
|
+
yep []
|
|
201
|
+
yep Hash.new
|
|
202
|
+
|
|
203
|
+
nope true
|
|
204
|
+
end
|
|
205
|
+
end
|
|
21
206
|
end
|
|
22
207
|
|
|
23
|
-
|
|
24
|
-
|
|
208
|
+
context "testing :refute_false()" do
|
|
209
|
+
should "pass all tests" do
|
|
210
|
+
testing_method :refute_false do
|
|
211
|
+
yep true
|
|
212
|
+
yep nil
|
|
213
|
+
yep 5
|
|
214
|
+
yep "string"
|
|
215
|
+
yep :symbol
|
|
216
|
+
yep []
|
|
217
|
+
yep Hash.new
|
|
218
|
+
|
|
219
|
+
nope false
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
context "testing :assert_nil()" do
|
|
225
|
+
should "pass all tests" do
|
|
226
|
+
testing_method :assert_nil do
|
|
227
|
+
yep nil
|
|
228
|
+
|
|
229
|
+
nope true
|
|
230
|
+
nope false
|
|
231
|
+
nope 5
|
|
232
|
+
nope "string"
|
|
233
|
+
nope :symbol
|
|
234
|
+
nope []
|
|
235
|
+
nope Hash.new
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
context "testing :refute_nil()" do
|
|
241
|
+
should "pass all tests" do
|
|
242
|
+
testing_method :refute_nil do
|
|
243
|
+
yep true
|
|
244
|
+
yep false
|
|
245
|
+
yep 5
|
|
246
|
+
yep "string"
|
|
247
|
+
yep :symbol
|
|
248
|
+
yep []
|
|
249
|
+
yep Hash.new # if not given parentheses, seen as a block not a hash.
|
|
250
|
+
|
|
251
|
+
nope nil
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
context "testing :assert_blank()" do
|
|
257
|
+
should "pass all tests" do
|
|
258
|
+
|
|
259
|
+
blank_obj = modded_object do
|
|
260
|
+
def blank?
|
|
261
|
+
true
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
fwfblank_obj = modded_object do
|
|
266
|
+
def fwf_blank?
|
|
267
|
+
true
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
not_blank_obj = modded_object do
|
|
272
|
+
def blank?
|
|
273
|
+
false
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
blank_error_obj = modded_object do
|
|
278
|
+
def fwf_blank?
|
|
279
|
+
raise StandardError.new("Raises error!")
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
blank_returns_5_obj = modded_object do
|
|
284
|
+
def fwf_blank?
|
|
285
|
+
5
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
testing_method :assert_responds_to_blank do
|
|
290
|
+
nope []
|
|
291
|
+
nope( {} )
|
|
292
|
+
nope ""
|
|
293
|
+
nope Object.new
|
|
294
|
+
nope Set.new
|
|
295
|
+
|
|
296
|
+
yep blank_obj
|
|
297
|
+
yep fwfblank_obj
|
|
298
|
+
yep not_blank_obj
|
|
299
|
+
yep blank_error_obj
|
|
300
|
+
yep blank_returns_5_obj
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
testing_method :assert_blank do
|
|
304
|
+
# As implemented, assert_blank first asserts the item responds to blank, causing its own error
|
|
305
|
+
nope []
|
|
306
|
+
nope( {} )
|
|
307
|
+
nope Set.new
|
|
308
|
+
nope ""
|
|
309
|
+
|
|
310
|
+
yep blank_obj
|
|
311
|
+
yep fwfblank_obj
|
|
312
|
+
|
|
313
|
+
nope not_blank_obj
|
|
314
|
+
|
|
315
|
+
oops blank_error_obj
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
context "testing :assert_matches()" do
|
|
321
|
+
should "pass all tests" do
|
|
322
|
+
testing_method :assert_matches do
|
|
323
|
+
yep "Why hello there!", /hello/
|
|
324
|
+
nope "Why HELLO there!", /hello/
|
|
325
|
+
yep "Why HELLO there!", /hello/i
|
|
326
|
+
|
|
327
|
+
yep "Why HELLO there!", "HELLO"
|
|
328
|
+
nope "Why HELLO there!", "hello"
|
|
329
|
+
|
|
330
|
+
oops 5, /oopsie/
|
|
331
|
+
oops "oops", :symbol
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
context "testing :refute_matches()" do
|
|
337
|
+
should "pass all tests" do
|
|
338
|
+
testing_method :refute_matches do
|
|
339
|
+
nope "Why hello there!", /hello/
|
|
340
|
+
yep "Why HELLO there!", /hello/
|
|
341
|
+
nope "Why HELLO there!", /hello/i
|
|
342
|
+
|
|
343
|
+
nope "Why HELLO there!", "HELLO"
|
|
344
|
+
yep "Why HELLO there!", "hello"
|
|
345
|
+
|
|
346
|
+
oops 5, /oopsie/
|
|
347
|
+
oops "oops", :symbol
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
context "testing :assert_greater_than()" do
|
|
353
|
+
should "pass all tests" do
|
|
354
|
+
testing_method :assert_greater_than do
|
|
355
|
+
yep 5, 5.1
|
|
356
|
+
yep( -4, -3 )
|
|
357
|
+
yep "a", "b"
|
|
358
|
+
nope 0, 0
|
|
359
|
+
nope 0, 0.0
|
|
360
|
+
nope 5.1, 5.0
|
|
361
|
+
nope( -4, -5 )
|
|
362
|
+
|
|
363
|
+
oops 5, nil
|
|
364
|
+
oops 6, []
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
context "testing :assert_less_than()" do
|
|
370
|
+
should "pass all tests" do
|
|
371
|
+
testing_method :assert_less_than do
|
|
372
|
+
yep 5, 4
|
|
373
|
+
yep "b", "a"
|
|
374
|
+
yep 100, 7.1
|
|
375
|
+
yep 0.0, -1
|
|
376
|
+
yep 0.999, 0.998
|
|
377
|
+
|
|
378
|
+
nope 0, 0
|
|
379
|
+
nope 0.0, 0
|
|
380
|
+
nope "a", "a"
|
|
381
|
+
nope( -1000, -100 )
|
|
382
|
+
nope 5, 6
|
|
383
|
+
|
|
384
|
+
oops 1000, "a"
|
|
385
|
+
oops "a", nil
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
context "testing :assert_at_most()" do
|
|
391
|
+
should "pass all tests" do
|
|
392
|
+
testing_method :assert_at_most do
|
|
393
|
+
yep 0, 0
|
|
394
|
+
yep 0, 0.0
|
|
395
|
+
yep 0.0, 0.0
|
|
396
|
+
yep 5, 3
|
|
397
|
+
yep 5, 1.4
|
|
398
|
+
|
|
399
|
+
nope 2, 6
|
|
400
|
+
nope( -12, -4 )
|
|
401
|
+
|
|
402
|
+
oops 5, []
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
context "testing :assert_at_least()" do
|
|
408
|
+
should "pass all tests" do
|
|
409
|
+
testing_method :assert_at_least do
|
|
410
|
+
yep 0, 0
|
|
411
|
+
yep 0, 0.0
|
|
412
|
+
yep 0.0, 0.0
|
|
413
|
+
yep 3, 5
|
|
414
|
+
yep 1.4, 5
|
|
415
|
+
|
|
416
|
+
nope 6, 2
|
|
417
|
+
nope( -4, -14 )
|
|
418
|
+
|
|
419
|
+
oops 5, []
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
context "testing :assert_times_are_close()" do
|
|
425
|
+
should "pass all tests" do
|
|
426
|
+
@ref_time = Time.now
|
|
427
|
+
|
|
428
|
+
testing_method( :assert_times_are_close ) do
|
|
429
|
+
yep @ref_time, @ref_time + 1
|
|
430
|
+
yep @ref_time, @ref_time + 0.3
|
|
431
|
+
yep @ref_time, @ref_time
|
|
432
|
+
yep @ref_time, @ref_time - 5, 20 # 20-second window given
|
|
433
|
+
|
|
434
|
+
nope @ref_time, @ref_time + 0.1, 0.01
|
|
435
|
+
nope @ref_time, @ref_time + 1.1
|
|
436
|
+
nope @ref_time, @ref_time - 1.1
|
|
437
|
+
nope @ref_time, @ref_time - 100
|
|
438
|
+
nope @ref_time, @ref_time - 100, 99
|
|
439
|
+
|
|
440
|
+
oops @ref_time, nil
|
|
441
|
+
oops @ref_time, []
|
|
442
|
+
end
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
context "testing :assert_equal_length()" do
|
|
447
|
+
should "pass all tests" do
|
|
448
|
+
testing_method( :assert_equal_length ) do
|
|
449
|
+
yep [], []
|
|
450
|
+
yep [], {}
|
|
451
|
+
yep [1,2,3,4,5], { 1 => :one, 2 => :two, 3 => :three, 4 => :four, 5 => :five}
|
|
452
|
+
yep Set.new, {}
|
|
453
|
+
yep [1,2,3,4,5], :hello
|
|
454
|
+
|
|
455
|
+
nope :hello, "goodbye"
|
|
456
|
+
nope [], { 1 => :one }
|
|
457
|
+
nope Set.new( [1,2,3] ), Set.new( [4,5,6,7] )
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
context "testing :assert_length()" do
|
|
463
|
+
should "pass all tests" do
|
|
464
|
+
testing_method :assert_length do
|
|
465
|
+
yep 0, ""
|
|
466
|
+
yep 0, :""
|
|
467
|
+
yep 1, [ :one ]
|
|
468
|
+
yep 0..5, { 1 => :one, 2 => :two, 3 => :three }
|
|
469
|
+
yep 0..140, "This string is tweetable!"
|
|
470
|
+
yep 1..3, "two"
|
|
471
|
+
yep 4, "four"
|
|
472
|
+
|
|
473
|
+
nope 0, "hi"
|
|
474
|
+
nope 0, [ 1 ]
|
|
475
|
+
nope 5, "five"
|
|
476
|
+
nope 1..3, [1, 2, 3, 4]
|
|
477
|
+
nope 3..5, nil
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
context "testing :assert_equality_of_methods()" do
|
|
483
|
+
should "pass all tests" do
|
|
484
|
+
testing_method :assert_equality_of_methods do
|
|
485
|
+
yep 7, 7, :to_s, :hash, :to_f
|
|
486
|
+
nope 3, 4, :to_s, :hash, :to_f
|
|
487
|
+
nope [], {}, :last # hash doesn't respond to last
|
|
488
|
+
nope 3, 4, :times
|
|
489
|
+
nope 3, 4, :respond_to? # ArgumentError for both
|
|
490
|
+
end
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
context "testing :assert_nothing_raised()" do
|
|
495
|
+
should "pass all tests" do
|
|
496
|
+
testing_method :assert_nothing_raised do
|
|
497
|
+
yep do
|
|
498
|
+
5 + 6
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
yep do
|
|
502
|
+
nil
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
nope do
|
|
506
|
+
raise StandardError.new( "whoops" )
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
# context "testing :555()" do
|
|
513
|
+
# should "pass all tests" do
|
|
514
|
+
# testing_method : do
|
|
515
|
+
# yep
|
|
516
|
+
# yep
|
|
517
|
+
# yep
|
|
518
|
+
# yep
|
|
519
|
+
# yep
|
|
520
|
+
# yep
|
|
521
|
+
|
|
522
|
+
# nope
|
|
523
|
+
# nope
|
|
524
|
+
# nope
|
|
525
|
+
# nope
|
|
526
|
+
# nope
|
|
527
|
+
# nope
|
|
528
|
+
|
|
529
|
+
# oops
|
|
530
|
+
# end
|
|
531
|
+
# end
|
|
532
|
+
# context "testing :555()" do
|
|
533
|
+
# should "pass all tests" do
|
|
534
|
+
# testing_method : do
|
|
535
|
+
# yep
|
|
536
|
+
# yep
|
|
537
|
+
# yep
|
|
538
|
+
# yep
|
|
539
|
+
# yep
|
|
540
|
+
# yep
|
|
541
|
+
|
|
542
|
+
# nope
|
|
543
|
+
# nope
|
|
544
|
+
# nope
|
|
545
|
+
# nope
|
|
546
|
+
# nope
|
|
547
|
+
# nope
|
|
548
|
+
|
|
549
|
+
# oops
|
|
550
|
+
# end
|
|
551
|
+
# end
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
context "testing instance assertions" do
|
|
555
|
+
should "assure us that classes have methods" do
|
|
556
|
+
instance_methods = {
|
|
557
|
+
Integer => [:to_s, :odd?, :even?, :times, :ceil],
|
|
558
|
+
Float => [:to_f],
|
|
559
|
+
Array => [:length, :each, :sort, :map],
|
|
560
|
+
Object => [:hash, :tap, :is_a?, :to_s]
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
testing_method :assert_has_instance_method do
|
|
564
|
+
for klass, methods in instance_methods
|
|
565
|
+
for method in methods
|
|
566
|
+
yep klass, method
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
should "assure us that classes don't have hinkey instance methods" do
|
|
573
|
+
instance_methods = {
|
|
574
|
+
Integer => [:to_p, :old?, :seven?, :timey, :seal],
|
|
575
|
+
Numeric => [:to_g],
|
|
576
|
+
Array => [:lanth, :eech, :sorta, :nap, :way_too_long?],
|
|
577
|
+
Object => [:hashbrown, :tarp, :is_also_a?, :to_sting]
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
testing_method :assert_has_instance_method do
|
|
581
|
+
for klass, methods in instance_methods
|
|
582
|
+
for method in methods
|
|
583
|
+
nope klass, method
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
end
|
|
587
|
+
end
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
context "testing length assertions" do
|
|
591
|
+
should "acknowledge the zerolengthiness of the empty array" do
|
|
592
|
+
@case.assert_length 0, []
|
|
593
|
+
@case.assert_length 17, %w(my mother told me to pick the very best one and the very best one is you)
|
|
594
|
+
@case.assert_equal_length [], []
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
context "testing assert_constant_defined" do
|
|
599
|
+
should "acknowledge the existence of the mighty Float class!" do
|
|
600
|
+
testing_method :assert_constant_defined do
|
|
601
|
+
yep "Float"
|
|
602
|
+
yep "FunWith::Testing"
|
|
603
|
+
yep "FunWith::Testing::TestAssertions"
|
|
604
|
+
yep "::Array"
|
|
605
|
+
yep "Enumerator::Lazy"
|
|
606
|
+
|
|
607
|
+
nope "Hippopotamus"
|
|
608
|
+
nope "FunWith::SpringLoaded::Walrus"
|
|
609
|
+
|
|
610
|
+
oops nil
|
|
611
|
+
oops
|
|
612
|
+
end
|
|
613
|
+
end
|
|
25
614
|
end
|
|
26
615
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
616
|
+
context "testing assert_included_module" do
|
|
617
|
+
should "recognize modules as included or not" do
|
|
618
|
+
testing_method :assert_includes_module do
|
|
619
|
+
yep File, Kernel
|
|
620
|
+
yep Numeric, Comparable
|
|
621
|
+
yep SyntaxError, Kernel
|
|
622
|
+
oops nil, 3
|
|
623
|
+
end
|
|
624
|
+
end
|
|
30
625
|
end
|
|
31
626
|
end
|
|
32
627
|
end
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class TestFunWithTesting < FunWith::Testing::MyTestCase
|
|
3
|
+
class TestFunWithTesting < FunTestCase
|
|
5
4
|
should "be plumbed properly" do
|
|
6
5
|
assert defined?( FunWith::Testing::Assertions )
|
|
7
|
-
assert defined?( FunWith::Testing::Assertions::ActiveRecord )
|
|
8
6
|
assert defined?( FunWith::Testing::Assertions::Basics )
|
|
9
7
|
|
|
10
8
|
assert_includes( FunWith::Testing::Assertions::Basics.instance_methods, :assert_blank )
|
|
11
9
|
assert_includes( FunWith::Testing::Assertions::Basics.instance_methods, :assert_blank )
|
|
12
10
|
assert_includes( FunWith::Testing::Assertions::Basics.instance_methods, :assert_greater_than )
|
|
13
11
|
assert_includes( FunWith::Testing::Assertions::Basics.instance_methods, :assert_zero )
|
|
14
|
-
assert_includes( FunWith::Testing::Assertions::ActiveRecord.instance_methods, :assert_no_errors_on )
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
should "have test/unit on board" do
|
|
18
15
|
assert( defined?( Minitest ), "problem loading Minitest" )
|
|
19
|
-
assert( defined?( Minitest::Test ), "problem loading Minitest" )
|
|
16
|
+
assert( defined?( Minitest::Test ), "problem loading Minitest::Test" )
|
|
20
17
|
end
|
|
21
18
|
|
|
22
19
|
should "access a listing of assertion modules" do
|
|
23
|
-
assert_includes( FunWith::Testing.included_modules, FunWith::Testing::Assertions::ActiveRecord )
|
|
24
20
|
assert_includes( FunWith::Testing.included_modules, FunWith::Testing::Assertions::Basics )
|
|
25
21
|
end
|
|
26
22
|
|
|
27
23
|
should "successfully get included in a subclass" do
|
|
28
|
-
klass = Class.new( Minitest::
|
|
24
|
+
klass = Class.new( Minitest::Test )
|
|
29
25
|
|
|
30
26
|
imethods = klass.instance_methods.select{|sym| sym.to_s =~ /^(assert|refute)_/ }
|
|
31
27
|
|
data/test/test_verbosity.rb
CHANGED
|
@@ -2,10 +2,11 @@ require 'helper'
|
|
|
2
2
|
|
|
3
3
|
module FunWith
|
|
4
4
|
module Testing
|
|
5
|
-
class TestVerbosity <
|
|
5
|
+
class TestVerbosity < AssertionsTestCase
|
|
6
6
|
context "testing in_test_mode?" do
|
|
7
7
|
setup do
|
|
8
8
|
extended_test_case
|
|
9
|
+
@case_class.install_verbosity
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
should "set into verbose by default" do
|