mofo 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/{tests → test}/fixtures/bob.html +0 -0
- data/{tests → test}/fixtures/chowhound.html +0 -0
- data/{tests → test}/fixtures/corkd.html +0 -0
- data/{tests → test}/fixtures/events.html +0 -0
- data/{tests → test}/fixtures/fake.html +0 -0
- data/{tests → test}/fixtures/fauxtank.html +0 -0
- data/{tests → test}/fixtures/hatom.html +0 -0
- data/{tests → test}/fixtures/simple.html +0 -0
- data/{tests → test}/fixtures/upcoming.html +0 -0
- data/{tests → test}/format_test.rb +1 -1
- data/{tests → test}/hatom_test.rb +1 -1
- data/{tests → test}/test_helper.rb +1 -1
- data/{tests → test}/xoxo_test.rb +1 -1
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/ChangeLog +57 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/README +85 -2
- data/vendor/testspec-0.3.0/ROADMAP +1 -0
- data/vendor/testspec-0.3.0/Rakefile +151 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/SPECS +11 -4
- data/vendor/testspec-0.3.0/TODO +2 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/bin/specrb +3 -2
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Kernel.html +35 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Object.html +12 -11
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec.html +3 -7
- data/vendor/testspec-0.3.0/doc/classes/Test/Spec/CustomShould.html +236 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/DefinitionError.html +0 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/Should.html +368 -347
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/ShouldNot.html +195 -119
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/TestCase.html +29 -29
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/TestCase/ClassMethods.html +83 -55
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Spec/TestCase/InstanceMethods.html +35 -35
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Unit/UI/RDox/TestRunner.html +24 -24
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/classes/Test/Unit/UI/SpecDox/TestRunner.html +185 -177
- data/vendor/testspec-0.3.0/doc/created.rid +1 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/README.html +111 -4
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/ROADMAP.html +2 -5
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/SPECS.html +26 -5
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/lib/test/spec/dox_rb.html +1 -1
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/lib/test/spec/rdox_rb.html +1 -1
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/lib/test/spec/should-output_rb.html +2 -1
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/lib/test/spec_rb.html +2 -2
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/fr_class_index.html +1 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/fr_file_index.html +0 -0
- data/vendor/testspec-0.3.0/doc/fr_method_index.html +102 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/index.html +0 -0
- data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/rdoc-style.css +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/examples/stack.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/examples/stack_spec.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/lib/test/spec.rb +167 -43
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/lib/test/spec/dox.rb +16 -8
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/lib/test/spec/rdox.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/lib/test/spec/should-output.rb +3 -2
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_dox.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_flexmock.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_mocha.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_nestedcontexts.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_should-output.rb +1 -1
- data/vendor/testspec-0.3.0/test/spec_testspec.rb +522 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/spec_testspec_order.rb +0 -0
- data/vendor/{testspec-0.2.0 → testspec-0.3.0}/test/test_testunit.rb +0 -0
- metadata +82 -81
- data/vendor/testspec-0.2.0/ROADMAP +0 -3
- data/vendor/testspec-0.2.0/Rakefile +0 -86
- data/vendor/testspec-0.2.0/TODO +0 -1
- data/vendor/testspec-0.2.0/rdoc/created.rid +0 -1
- data/vendor/testspec-0.2.0/rdoc/fr_method_index.html +0 -95
- data/vendor/testspec-0.2.0/test/spec_testspec.rb +0 -311
@@ -0,0 +1 @@
|
|
1
|
+
Wed Jan 24 12:13:34 CET 2007
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed
|
59
|
+
<td>Wed Jan 24 12:13:27 CET 2007</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -71,7 +71,7 @@
|
|
71
71
|
<div id="description">
|
72
72
|
<h1>test/spec, a BDD interface for Test::Unit</h1>
|
73
73
|
<p>
|
74
|
-
Copyright (C) 2006 Christian Neukirchen <<a
|
74
|
+
Copyright (C) 2006, 2007 Christian Neukirchen <<a
|
75
75
|
href="mailto:chneukirchen@gmail.com">chneukirchen@gmail.com</a>>
|
76
76
|
</p>
|
77
77
|
<h2>What is test/spec?</h2>
|
@@ -126,7 +126,8 @@ should not do any harm, but if you know a way around it, please tell me.)
|
|
126
126
|
</p>
|
127
127
|
<p>
|
128
128
|
test/spec adds two global methods, <a
|
129
|
-
href="../classes/Object.html#M000001">Object#should</a> and
|
129
|
+
href="../classes/Object.html#M000001">Object#should</a> and <a
|
130
|
+
href="../classes/Kernel.html#M000002">Kernel.context</a>.
|
130
131
|
</p>
|
131
132
|
<p>
|
132
133
|
You can use <tt>assert_*</tt> freely in specify-blocks; <a
|
@@ -220,6 +221,58 @@ a.</tt><em>predicate</em><tt>?</tt>)
|
|
220
221
|
If you write an useful general-purpose assertion, I’d like to hear of
|
221
222
|
it and may add it to the test/spec distribution.
|
222
223
|
</p>
|
224
|
+
<h2>Messaging/Blaming</h2>
|
225
|
+
<p>
|
226
|
+
With more complex assertions, it may be helpful to provide a message to
|
227
|
+
show if the assertion has failed. This can be done with the Should#blaming
|
228
|
+
or Should#messaging methods:
|
229
|
+
</p>
|
230
|
+
<pre>
|
231
|
+
RUBY_VERSION.should.messaging("Ruby too old.").be > "1.8.4"
|
232
|
+
|
233
|
+
(1 + 1).should.blaming("weird math").not.equal 11
|
234
|
+
</pre>
|
235
|
+
<h2>Custom shoulds ("Matchers")</h2>
|
236
|
+
<p>
|
237
|
+
To capture recurring patterns in parts of your specifications, you can
|
238
|
+
define custom "shoulds" (RSpec calls them "matchers")
|
239
|
+
in your contexts, or include modules of them:
|
240
|
+
</p>
|
241
|
+
<pre>
|
242
|
+
context "Numbers"
|
243
|
+
class EqualString < Test::Spec::CustomShould
|
244
|
+
def matches?(other)
|
245
|
+
object == other.to_s
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def equal_string(str)
|
250
|
+
EqualString.new(str)
|
251
|
+
end
|
252
|
+
|
253
|
+
specify "should have to_s"
|
254
|
+
42.should equal_string("42")
|
255
|
+
end
|
256
|
+
end
|
257
|
+
</pre>
|
258
|
+
<p>
|
259
|
+
Alternatively, your implementation can define CustomShould#assumptions,
|
260
|
+
where you can use test/spec assertions instead of Boolean predicates:
|
261
|
+
</p>
|
262
|
+
<pre>
|
263
|
+
class EqualString < Test::Spec::CustomShould
|
264
|
+
def assumptions(other)
|
265
|
+
object.should.equal other.to_s
|
266
|
+
end
|
267
|
+
end
|
268
|
+
</pre>
|
269
|
+
<p>
|
270
|
+
A CustomShould by default takes one argument, which is placed in
|
271
|
+
self.object for your convenience.
|
272
|
+
</p>
|
273
|
+
<p>
|
274
|
+
You can CustomShould#failure_message to provide a better error message.
|
275
|
+
</p>
|
223
276
|
<h2>SpecDox and RDox</h2>
|
224
277
|
<p>
|
225
278
|
test/spec adds two additional test runners to Test::Unit, based on the
|
@@ -260,6 +313,12 @@ SpecDox and RDox work for Test::Unit too:
|
|
260
313
|
|
261
314
|
3 specifications (30 requirements), 0 failures
|
262
315
|
</pre>
|
316
|
+
<h2>Disabled specifications</h2>
|
317
|
+
<p>
|
318
|
+
Akin to the usual Test::Unit practice, tests quickly can be disabled by
|
319
|
+
replacing <tt>specify</tt> with <tt>xspecify</tt>. test/spec will count the
|
320
|
+
disabled tests when you run it with SpecDox or RDox.
|
321
|
+
</p>
|
263
322
|
<h2>specrb</h2>
|
264
323
|
<p>
|
265
324
|
Since version 0.2, test/spec features a standalone test runner called
|
@@ -282,6 +341,20 @@ Test::Unit suites, too.
|
|
282
341
|
<p>
|
283
342
|
Run <tt>specrb —help</tt> for the usage.
|
284
343
|
</p>
|
344
|
+
<h2>Installing with RubyGems</h2>
|
345
|
+
<p>
|
346
|
+
Since version 0.3, a Gem of test/spec is available. You can install with:
|
347
|
+
</p>
|
348
|
+
<pre>
|
349
|
+
gem install test-spec
|
350
|
+
</pre>
|
351
|
+
<p>
|
352
|
+
I also provide a local mirror of the gems (and development snapshots) at my
|
353
|
+
site:
|
354
|
+
</p>
|
355
|
+
<pre>
|
356
|
+
gem install test-spec --source http://chneukirchen.org/releases/gems
|
357
|
+
</pre>
|
285
358
|
<h2>History</h2>
|
286
359
|
<ul>
|
287
360
|
<li>September 29th, 2006: First public release 0.1.
|
@@ -307,6 +380,34 @@ Run <tt>specrb —help</tt> for the usage.
|
|
307
380
|
</li>
|
308
381
|
<li>Standalone test/spec runner, specrb
|
309
382
|
|
383
|
+
</li>
|
384
|
+
</ul>
|
385
|
+
</li>
|
386
|
+
<li>January 24th, 2007: Third public release 0.3.
|
387
|
+
|
388
|
+
<ul>
|
389
|
+
<li>should.be_close, should.be_an_instance_of, should.be_a_kind_of, and
|
390
|
+
should.be_nil have been deprecated. Use the dot-variants of them. These
|
391
|
+
assertions will be removed in 1.0.
|
392
|
+
|
393
|
+
</li>
|
394
|
+
<li>specrb -a now includes -Ilib by default for easier out-of-the-box testing.
|
395
|
+
|
396
|
+
</li>
|
397
|
+
<li>Added custom shoulds.
|
398
|
+
|
399
|
+
</li>
|
400
|
+
<li>Added messaging/blaming.
|
401
|
+
|
402
|
+
</li>
|
403
|
+
<li>Added disabling of specifications.
|
404
|
+
|
405
|
+
</li>
|
406
|
+
<li>Small bug fixes.
|
407
|
+
|
408
|
+
</li>
|
409
|
+
<li>Gem available.
|
410
|
+
|
310
411
|
</li>
|
311
412
|
</ul>
|
312
413
|
</li>
|
@@ -324,6 +425,12 @@ href="http://chneukirchen.org/repos/testspec">chneukirchen.org/repos/testspec</a
|
|
324
425
|
<ul>
|
325
426
|
<li>Eero Saynatkari for writing <tt>should.output</tt>.
|
326
427
|
|
428
|
+
</li>
|
429
|
+
<li>Jean-Michel Garnier for packaging the first gem.
|
430
|
+
|
431
|
+
</li>
|
432
|
+
<li>Mikko Lehtonen for testing the gem.
|
433
|
+
|
327
434
|
</li>
|
328
435
|
<li>Thomas Fuchs for script.aculo.us BDD testing which convinced me.
|
329
436
|
|
@@ -340,7 +447,7 @@ href="http://chneukirchen.org/repos/testspec">chneukirchen.org/repos/testspec</a
|
|
340
447
|
</ul>
|
341
448
|
<h2>Copying</h2>
|
342
449
|
<p>
|
343
|
-
Copyright (C) 2006 Christian Neukirchen <<a
|
450
|
+
Copyright (C) 2006, 2007 Christian Neukirchen <<a
|
344
451
|
href="http://purl.org/net/chneukirchen">purl.org/net/chneukirchen</a>>
|
345
452
|
</p>
|
346
453
|
<p>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed
|
59
|
+
<td>Wed Jan 24 12:13:27 CET 2007</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,10 +70,7 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<table>
|
73
|
-
<tr><td valign="top">Version 0
|
74
|
-
|
75
|
-
</td></tr>
|
76
|
-
<tr><td valign="top">Version 1.0 (Late November 2006):</td><td>first stable release.
|
73
|
+
<tr><td valign="top">Version 1.0 (February 2006):</td><td>first stable release.
|
77
74
|
|
78
75
|
</td></tr>
|
79
76
|
</table>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed
|
59
|
+
<td>Wed Jan 24 12:13:33 CET 2007</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -239,16 +239,16 @@ should_ignore_missing
|
|
239
239
|
<li>should.raise should return the exception
|
240
240
|
|
241
241
|
</li>
|
242
|
-
<li>has should.
|
242
|
+
<li>has should.be.an.instance_of
|
243
243
|
|
244
244
|
</li>
|
245
|
-
<li>has should.
|
245
|
+
<li>has should.be.nil
|
246
246
|
|
247
247
|
</li>
|
248
248
|
<li>has should.include
|
249
249
|
|
250
250
|
</li>
|
251
|
-
<li>has should.
|
251
|
+
<li>has should.be.a.kind_of
|
252
252
|
|
253
253
|
</li>
|
254
254
|
<li>has should.match
|
@@ -259,6 +259,9 @@ should_ignore_missing
|
|
259
259
|
</li>
|
260
260
|
<li>has should.not.raise
|
261
261
|
|
262
|
+
</li>
|
263
|
+
<li>has should.not.satisfy
|
264
|
+
|
262
265
|
</li>
|
263
266
|
<li>has should.not.be
|
264
267
|
|
@@ -292,6 +295,24 @@ should_ignore_missing
|
|
292
295
|
</li>
|
293
296
|
<li>is robust against careless users
|
294
297
|
|
298
|
+
</li>
|
299
|
+
<li>should detect warnings
|
300
|
+
|
301
|
+
</li>
|
302
|
+
<li>should message/blame faults
|
303
|
+
|
304
|
+
</li>
|
305
|
+
<li>should allow for custom shoulds
|
306
|
+
|
307
|
+
</li>
|
308
|
+
<li>disabled specification (disabled)
|
309
|
+
|
310
|
+
</li>
|
311
|
+
</ul>
|
312
|
+
<h3>more disabled</h3>
|
313
|
+
<ul>
|
314
|
+
<li>this is intentional (disabled)
|
315
|
+
|
295
316
|
</li>
|
296
317
|
</ul>
|
297
318
|
<h2>setup/teardown</h2>
|
@@ -328,7 +349,7 @@ should_ignore_missing
|
|
328
349
|
</li>
|
329
350
|
</ul>
|
330
351
|
<p>
|
331
|
-
|
352
|
+
76 specifications, 2 disabled (414 requirements), 0 failures
|
332
353
|
</p>
|
333
354
|
|
334
355
|
</div>
|
data/vendor/{testspec-0.2.0/rdoc → testspec-0.3.0/doc}/files/lib/test/spec/should-output_rb.html
RENAMED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed
|
59
|
+
<td>Wed Jan 24 12:13:27 CET 2007</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -80,6 +80,7 @@ Code adapted from rs, written by Eero Saynatkari.
|
|
80
80
|
|
81
81
|
<div class="name-list">
|
82
82
|
fileutils
|
83
|
+
tmpdir
|
83
84
|
</div>
|
84
85
|
</div>
|
85
86
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Wed
|
59
|
+
<td>Wed Jan 24 12:13:27 CET 2007</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -73,7 +73,7 @@
|
|
73
73
|
test/spec — a BDD interface for Test::Unit
|
74
74
|
</p>
|
75
75
|
<p>
|
76
|
-
Copyright (C) 2006 Christian Neukirchen <<a
|
76
|
+
Copyright (C) 2006, 2007 Christian Neukirchen <<a
|
77
77
|
href="mailto:chneukirchen@gmail.com">chneukirchen@gmail.com</a>>
|
78
78
|
</p>
|
79
79
|
<p>
|
@@ -23,6 +23,7 @@
|
|
23
23
|
<a href="classes/Kernel.html">Kernel</a><br />
|
24
24
|
<a href="classes/Object.html">Object</a><br />
|
25
25
|
<a href="classes/Test/Spec.html">Test::Spec</a><br />
|
26
|
+
<a href="classes/Test/Spec/CustomShould.html">Test::Spec::CustomShould</a><br />
|
26
27
|
<a href="classes/Test/Spec/DefinitionError.html">Test::Spec::DefinitionError</a><br />
|
27
28
|
<a href="classes/Test/Spec/Should.html">Test::Spec::Should</a><br />
|
28
29
|
<a href="classes/Test/Spec/ShouldNot.html">Test::Spec::ShouldNot</a><br />
|
File without changes
|
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
3
|
+
<!DOCTYPE html
|
4
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
5
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
<!--
|
8
|
+
|
9
|
+
Methods
|
10
|
+
|
11
|
+
-->
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
13
|
+
<head>
|
14
|
+
<title>Methods</title>
|
15
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
16
|
+
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
|
17
|
+
<base target="docwin" />
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div id="index">
|
21
|
+
<h1 class="section-bar">Methods</h1>
|
22
|
+
<div id="index-entries">
|
23
|
+
<a href="classes/Test/Spec/Should.html#M000055">< (Test::Spec::Should)</a><br />
|
24
|
+
<a href="classes/Test/Spec/Should.html#M000056"><= (Test::Spec::Should)</a><br />
|
25
|
+
<a href="classes/Test/Spec/Should.html#M000041">== (Test::Spec::Should)</a><br />
|
26
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000017">== (Test::Spec::ShouldNot)</a><br />
|
27
|
+
<a href="classes/Test/Spec/Should.html#M000057">=== (Test::Spec::Should)</a><br />
|
28
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000020">=~ (Test::Spec::ShouldNot)</a><br />
|
29
|
+
<a href="classes/Test/Spec/Should.html#M000045">=~ (Test::Spec::Should)</a><br />
|
30
|
+
<a href="classes/Test/Spec/Should.html#M000053">> (Test::Spec::Should)</a><br />
|
31
|
+
<a href="classes/Test/Spec/Should.html#M000054">>= (Test::Spec::Should)</a><br />
|
32
|
+
<a href="classes/Test/Spec/Should.html#M000049">_raise (Test::Spec::Should)</a><br />
|
33
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000021">_raise (Test::Spec::ShouldNot)</a><br />
|
34
|
+
<a href="classes/Test/Spec/Should.html#M000035">a (Test::Spec::Should)</a><br />
|
35
|
+
<a href="classes/Test/Spec/TestCase.html#M000004">add (Test::Spec::TestCase)</a><br />
|
36
|
+
<a href="classes/Test/Spec/Should.html#M000033">add_assertion (Test::Spec::Should)</a><br />
|
37
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000066">add_fault (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
38
|
+
<a href="classes/Test/Spec/Should.html#M000034">an (Test::Spec::Should)</a><br />
|
39
|
+
<a href="classes/Test/Spec/CustomShould.html#M000031">assumptions (Test::Spec::CustomShould)</a><br />
|
40
|
+
<a href="classes/Test/Spec/Should.html#M000043">be (Test::Spec::Should)</a><br />
|
41
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000018">be (Test::Spec::ShouldNot)</a><br />
|
42
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000024">be_nil (Test::Spec::ShouldNot)</a><br />
|
43
|
+
<a href="classes/Test/Spec/Should.html#M000038">blaming (Test::Spec::Should)</a><br />
|
44
|
+
<a href="classes/Test/Spec/Should.html#M000042">close (Test::Spec::Should)</a><br />
|
45
|
+
<a href="classes/Test/Spec/TestCase/InstanceMethods.html#M000013">context (Test::Spec::TestCase::InstanceMethods)</a><br />
|
46
|
+
<a href="classes/Kernel.html#M000002">context (Kernel)</a><br />
|
47
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000005">context (Test::Spec::TestCase::ClassMethods)</a><br />
|
48
|
+
<a href="classes/Test/Spec/Should.html#M000040">equal (Test::Spec::Should)</a><br />
|
49
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000016">equal (Test::Spec::ShouldNot)</a><br />
|
50
|
+
<a href="classes/Test/Spec/CustomShould.html#M000029">failure_message (Test::Spec::CustomShould)</a><br />
|
51
|
+
<a href="classes/Test/Unit/UI/RDox/TestRunner.html#M000063">finished (Test::Unit::UI::RDox::TestRunner)</a><br />
|
52
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000068">finished (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
53
|
+
<a href="classes/Test/Spec/Should.html#M000052">include (Test::Spec::Should)</a><br />
|
54
|
+
<a href="classes/Test/Unit/UI/RDox/TestRunner.html#M000064">indent (Test::Unit::UI::RDox::TestRunner)</a><br />
|
55
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000076">indent (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
56
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000010">init (Test::Spec::TestCase::ClassMethods)</a><br />
|
57
|
+
<a href="classes/Test/Spec/Should.html#M000046">instance_of (Test::Spec::Should)</a><br />
|
58
|
+
<a href="classes/Test/Spec/Should.html#M000047">kind_of (Test::Spec::Should)</a><br />
|
59
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000019">match (Test::Spec::ShouldNot)</a><br />
|
60
|
+
<a href="classes/Test/Spec/Should.html#M000044">match (Test::Spec::Should)</a><br />
|
61
|
+
<a href="classes/Test/Spec/CustomShould.html#M000030">matches? (Test::Spec::CustomShould)</a><br />
|
62
|
+
<a href="classes/Test/Spec/Should.html#M000037">messaging (Test::Spec::Should)</a><br />
|
63
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000027">method_missing (Test::Spec::ShouldNot)</a><br />
|
64
|
+
<a href="classes/Test/Spec/Should.html#M000059">method_missing (Test::Spec::Should)</a><br />
|
65
|
+
<a href="classes/Test/Spec/CustomShould.html#M000028">new (Test::Spec::CustomShould)</a><br />
|
66
|
+
<a href="classes/Test/Spec/Should.html#M000032">new (Test::Spec::Should)</a><br />
|
67
|
+
<a href="classes/Test/Spec/TestCase.html#M000003">new (Test::Spec::TestCase)</a><br />
|
68
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000014">new (Test::Spec::ShouldNot)</a><br />
|
69
|
+
<a href="classes/Test/Spec/TestCase/InstanceMethods.html#M000011">new (Test::Spec::TestCase::InstanceMethods)</a><br />
|
70
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000023">nil (Test::Spec::ShouldNot)</a><br />
|
71
|
+
<a href="classes/Test/Spec/Should.html#M000051">nil (Test::Spec::Should)</a><br />
|
72
|
+
<a href="classes/Test/Spec/Should.html#M000036">not (Test::Spec::Should)</a><br />
|
73
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000025">not (Test::Spec::ShouldNot)</a><br />
|
74
|
+
<a href="classes/Test/Spec/Should.html#M000060">output (Test::Spec::Should)</a><br />
|
75
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000074">output_heading (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
76
|
+
<a href="classes/Test/Unit/UI/RDox/TestRunner.html#M000061">output_heading (Test::Unit::UI::RDox::TestRunner)</a><br />
|
77
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000073">output_item (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
78
|
+
<a href="classes/Test/Unit/UI/RDox/TestRunner.html#M000062">output_item (Test::Unit::UI::RDox::TestRunner)</a><br />
|
79
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000072">output_no_nl (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
80
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000069">output_result (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
81
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000026">pass (Test::Spec::ShouldNot)</a><br />
|
82
|
+
<a href="classes/Test/Spec/Should.html#M000058">pass (Test::Spec::Should)</a><br />
|
83
|
+
<a href="classes/Test/Spec/TestCase/InstanceMethods.html#M000012">position (Test::Spec::TestCase::InstanceMethods)</a><br />
|
84
|
+
<a href="classes/Test/Spec/Should.html#M000048">respond_to (Test::Spec::Should)</a><br />
|
85
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000015">satisfy (Test::Spec::ShouldNot)</a><br />
|
86
|
+
<a href="classes/Test/Spec/Should.html#M000039">satisfy (Test::Spec::Should)</a><br />
|
87
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000008">setup (Test::Spec::TestCase::ClassMethods)</a><br />
|
88
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000065">setup_mediator (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
89
|
+
<a href="classes/Object.html#M000001">should (Object)</a><br />
|
90
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000006">specify (Test::Spec::TestCase::ClassMethods)</a><br />
|
91
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000067">started (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
92
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000009">teardown (Test::Spec::TestCase::ClassMethods)</a><br />
|
93
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000071">test_finished (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
94
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000070">test_started (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
95
|
+
<a href="classes/Test/Spec/ShouldNot.html#M000022">throw (Test::Spec::ShouldNot)</a><br />
|
96
|
+
<a href="classes/Test/Spec/Should.html#M000050">throw (Test::Spec::Should)</a><br />
|
97
|
+
<a href="classes/Test/Unit/UI/SpecDox/TestRunner.html#M000075">unmangle (Test::Unit::UI::SpecDox::TestRunner)</a><br />
|
98
|
+
<a href="classes/Test/Spec/TestCase/ClassMethods.html#M000007">xspecify (Test::Spec::TestCase::ClassMethods)</a><br />
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
</body>
|
102
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# test/spec -- a BDD interface for Test::Unit
|
3
3
|
#
|
4
|
-
# Copyright (C) 2006 Christian Neukirchen <mailto:chneukirchen@gmail.com>
|
4
|
+
# Copyright (C) 2006, 2007 Christian Neukirchen <mailto:chneukirchen@gmail.com>
|
5
5
|
#
|
6
6
|
# This work is licensed under the same terms as Ruby itself.
|
7
7
|
#
|
@@ -24,9 +24,9 @@ module Test # :nodoc:
|
|
24
24
|
end
|
25
25
|
|
26
26
|
module Test::Spec
|
27
|
-
VERSION = "0.
|
27
|
+
VERSION = "0.3"
|
28
28
|
|
29
|
-
CONTEXTS = {}
|
29
|
+
CONTEXTS = {} # :nodoc:
|
30
30
|
|
31
31
|
class DefinitionError < StandardError
|
32
32
|
end
|
@@ -34,8 +34,16 @@ module Test::Spec
|
|
34
34
|
class Should
|
35
35
|
include Test::Unit::Assertions
|
36
36
|
|
37
|
-
def
|
37
|
+
def self.deprecated_alias(to, from) # :nodoc:
|
38
|
+
define_method(to) { |*args|
|
39
|
+
warn "Test::Spec::Should##{to} is deprecated and will be removed in future versions."
|
40
|
+
__send__ from, *args
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize(object, message=nil)
|
38
45
|
@object = object
|
46
|
+
@message = message
|
39
47
|
end
|
40
48
|
|
41
49
|
$TEST_SPEC_TESTCASE = nil
|
@@ -52,96 +60,121 @@ module Test::Spec
|
|
52
60
|
self
|
53
61
|
end
|
54
62
|
|
55
|
-
def not
|
56
|
-
|
63
|
+
def not(*args)
|
64
|
+
case args.size
|
65
|
+
when 0
|
66
|
+
ShouldNot.new(@object, @message)
|
67
|
+
when 1
|
68
|
+
ShouldNot.new(@object, @message).pass(args.first)
|
69
|
+
else
|
70
|
+
raise ArgumentError, "#not takes zero or one argument(s)."
|
71
|
+
end
|
57
72
|
end
|
58
73
|
|
74
|
+
def messaging(message)
|
75
|
+
@message = message.to_s
|
76
|
+
self
|
77
|
+
end
|
78
|
+
alias blaming messaging
|
59
79
|
|
60
80
|
def satisfy(&block)
|
61
|
-
assert_block("satisfy block failed.") {
|
81
|
+
assert_block(@message || "satisfy block failed.") {
|
62
82
|
yield @object
|
63
83
|
}
|
64
84
|
end
|
65
85
|
|
66
86
|
def equal(value)
|
67
|
-
assert_equal value, @object
|
87
|
+
assert_equal value, @object, @message
|
68
88
|
end
|
69
89
|
alias == equal
|
70
90
|
|
71
91
|
def close(value, delta)
|
72
|
-
assert_in_delta value, @object, delta
|
92
|
+
assert_in_delta value, @object, delta, @message
|
73
93
|
end
|
74
|
-
|
94
|
+
deprecated_alias :be_close, :close
|
75
95
|
|
76
96
|
def be(*value)
|
77
97
|
case value.size
|
78
98
|
when 0
|
79
99
|
self
|
80
100
|
when 1
|
81
|
-
|
101
|
+
if CustomShould === value.first
|
102
|
+
pass value.first
|
103
|
+
else
|
104
|
+
assert_same value.first, @object, @message
|
105
|
+
end
|
82
106
|
else
|
83
107
|
raise ArgumentError, "should.be needs zero or one argument"
|
84
108
|
end
|
85
109
|
end
|
86
110
|
|
87
111
|
def match(value)
|
88
|
-
assert_match value, @object
|
112
|
+
assert_match value, @object, @message
|
89
113
|
end
|
90
114
|
alias =~ match
|
91
115
|
|
92
116
|
def instance_of(klass)
|
93
|
-
assert_instance_of klass, @object
|
117
|
+
assert_instance_of klass, @object, @message
|
94
118
|
end
|
95
|
-
|
119
|
+
deprecated_alias :be_an_instance_of, :instance_of
|
96
120
|
|
97
121
|
def kind_of(klass)
|
98
|
-
assert_kind_of klass, @object
|
122
|
+
assert_kind_of klass, @object, @message
|
99
123
|
end
|
100
|
-
|
124
|
+
deprecated_alias :be_a_kind_of, :kind_of
|
101
125
|
|
102
126
|
def respond_to(method)
|
103
|
-
assert_respond_to @object, method
|
127
|
+
assert_respond_to @object, method, @message
|
104
128
|
end
|
105
129
|
|
106
130
|
def _raise(*args)
|
107
131
|
args = [RuntimeError] if args.empty?
|
108
|
-
assert_raise(*args, &@object)
|
132
|
+
assert_raise(*(args + [@message]), &@object)
|
109
133
|
end
|
110
134
|
|
111
135
|
def throw(*args)
|
112
|
-
assert_throws(*args, &@object)
|
136
|
+
assert_throws(*(args + [@message]), &@object)
|
113
137
|
end
|
114
138
|
|
115
139
|
def nil
|
116
|
-
assert_nil @object
|
140
|
+
assert_nil @object, @message
|
117
141
|
end
|
118
|
-
|
142
|
+
deprecated_alias :be_nil, :nil
|
119
143
|
|
120
144
|
|
121
145
|
def include(value)
|
122
|
-
msg = build_message(
|
146
|
+
msg = build_message(@message, "<?> expected to include ?, but it didn't.",
|
123
147
|
@object, value)
|
124
148
|
assert_block(msg) { @object.include?(value) }
|
125
149
|
end
|
126
150
|
|
127
151
|
def >(value)
|
128
|
-
assert_operator @object, :>, value
|
152
|
+
assert_operator @object, :>, value, @message
|
129
153
|
end
|
130
154
|
|
131
155
|
def >=(value)
|
132
|
-
assert_operator @object, :>=, value
|
156
|
+
assert_operator @object, :>=, value, @message
|
133
157
|
end
|
134
158
|
|
135
159
|
def <(value)
|
136
|
-
assert_operator @object, :<, value
|
160
|
+
assert_operator @object, :<, value, @message
|
137
161
|
end
|
138
162
|
|
139
163
|
def <=(value)
|
140
|
-
assert_operator @object, :<=, value
|
164
|
+
assert_operator @object, :<=, value, @message
|
141
165
|
end
|
142
166
|
|
143
167
|
def ===(value)
|
144
|
-
assert_operator @object, :===, value
|
168
|
+
assert_operator @object, :===, value, @message
|
169
|
+
end
|
170
|
+
|
171
|
+
def pass(custom)
|
172
|
+
_wrap_assertion {
|
173
|
+
assert_nothing_raised(Test::Unit::AssertionFailedError,
|
174
|
+
@message || custom.failure_message) {
|
175
|
+
assert custom.matches?(@object), @message || custom.failure_message
|
176
|
+
}
|
177
|
+
}
|
145
178
|
end
|
146
179
|
|
147
180
|
def method_missing(name, *args)
|
@@ -150,7 +183,7 @@ module Test::Spec
|
|
150
183
|
|
151
184
|
if @object.respond_to?("#{name}?")
|
152
185
|
assert @object.__send__("#{name}?", *args),
|
153
|
-
|
186
|
+
"#{name}? expected to be true. #{@message}"
|
154
187
|
else
|
155
188
|
super
|
156
189
|
end
|
@@ -160,12 +193,19 @@ module Test::Spec
|
|
160
193
|
class ShouldNot
|
161
194
|
include Test::Unit::Assertions
|
162
195
|
|
163
|
-
def initialize(object)
|
196
|
+
def initialize(object, message=nil)
|
164
197
|
@object = object
|
198
|
+
@message = message
|
199
|
+
end
|
200
|
+
|
201
|
+
def satisfy(&block)
|
202
|
+
assert_block(@message || "not.satisfy block succeded.") {
|
203
|
+
not yield @object
|
204
|
+
}
|
165
205
|
end
|
166
206
|
|
167
207
|
def equal(value)
|
168
|
-
assert_not_equal value, @object
|
208
|
+
assert_not_equal value, @object, @message
|
169
209
|
end
|
170
210
|
alias == equal
|
171
211
|
|
@@ -174,7 +214,11 @@ module Test::Spec
|
|
174
214
|
when 0
|
175
215
|
self
|
176
216
|
when 1
|
177
|
-
|
217
|
+
if CustomShould === value.first
|
218
|
+
pass value.first
|
219
|
+
else
|
220
|
+
assert_not_same value.first, @object, @message
|
221
|
+
end
|
178
222
|
else
|
179
223
|
Kernel.raise ArgumentError, "should.be needs zero or one argument"
|
180
224
|
end
|
@@ -182,42 +226,80 @@ module Test::Spec
|
|
182
226
|
|
183
227
|
def match(value)
|
184
228
|
# Icky Regexp check
|
185
|
-
assert_no_match value, @object
|
229
|
+
assert_no_match value, @object, @message
|
186
230
|
end
|
187
231
|
alias =~ match
|
188
232
|
|
189
233
|
def _raise(*args)
|
190
|
-
assert_nothing_raised(*args, &@object)
|
234
|
+
assert_nothing_raised(*(args+[@message]), &@object)
|
191
235
|
end
|
192
236
|
|
193
237
|
def throw
|
194
|
-
assert_nothing_thrown(&@object)
|
238
|
+
assert_nothing_thrown(@message, &@object)
|
195
239
|
end
|
196
240
|
|
197
241
|
def nil
|
198
|
-
assert_not_nil @object
|
242
|
+
assert_not_nil @object, @message
|
199
243
|
end
|
200
|
-
alias be_nil nil
|
201
244
|
|
245
|
+
def be_nil
|
246
|
+
warn "Test::Spec::ShouldNot#be_nil is deprecated and will be removed in future versions."
|
247
|
+
self.nil
|
248
|
+
end
|
202
249
|
|
203
|
-
def not
|
204
|
-
|
250
|
+
def not(*args)
|
251
|
+
case args.size
|
252
|
+
when 0
|
253
|
+
Should.new(@object, @message)
|
254
|
+
when 1
|
255
|
+
Should.new(@object, @message).pass(args.first)
|
256
|
+
else
|
257
|
+
raise ArgumentError, "#not takes zero or one argument(s)."
|
258
|
+
end
|
205
259
|
end
|
206
260
|
|
261
|
+
def pass(custom)
|
262
|
+
_wrap_assertion {
|
263
|
+
begin
|
264
|
+
assert !custom.matches?(@object), @message || custom.failure_message
|
265
|
+
end
|
266
|
+
}
|
267
|
+
end
|
207
268
|
|
208
269
|
def method_missing(name, *args)
|
209
270
|
# This will make raise call Kernel.raise, and self.raise call _raise.
|
210
271
|
return _raise(*args) if name == :raise
|
211
272
|
|
212
273
|
if @object.respond_to?("#{name}?")
|
213
|
-
assert_block("#{name}? expected to be false.") {
|
274
|
+
assert_block("#{name}? expected to be false. #{@message}") {
|
214
275
|
not @object.__send__("#{name}?", *args)
|
215
276
|
}
|
216
277
|
else
|
217
278
|
super
|
218
279
|
end
|
219
280
|
end
|
281
|
+
|
282
|
+
end
|
220
283
|
|
284
|
+
class CustomShould
|
285
|
+
attr_accessor :object
|
286
|
+
|
287
|
+
def initialize(obj)
|
288
|
+
self.object = obj
|
289
|
+
end
|
290
|
+
|
291
|
+
def failure_message
|
292
|
+
"#{self.class.name} failed"
|
293
|
+
end
|
294
|
+
|
295
|
+
def matches?(*args, &block)
|
296
|
+
assumptions(*args, &block)
|
297
|
+
true
|
298
|
+
end
|
299
|
+
|
300
|
+
def assumptions(*args, &block)
|
301
|
+
raise NotImplementedError, "you need to supply a #{self.class}#matches? method"
|
302
|
+
end
|
221
303
|
end
|
222
304
|
end
|
223
305
|
|
@@ -277,6 +359,14 @@ class Test::Spec::TestCase
|
|
277
359
|
|
278
360
|
define_method("test_spec {%s} %03d [%s]" % [name, count, specname], &block)
|
279
361
|
end
|
362
|
+
|
363
|
+
def xspecify(specname, &block)
|
364
|
+
raise ArgumentError, "xspecify needs a block" if block.nil?
|
365
|
+
|
366
|
+
specify specname do
|
367
|
+
@_result.add_disabled(specname)
|
368
|
+
end
|
369
|
+
end
|
280
370
|
|
281
371
|
def setup(&block)
|
282
372
|
setups << block
|
@@ -322,6 +412,24 @@ class Test::Spec::TestCase
|
|
322
412
|
end
|
323
413
|
end
|
324
414
|
|
415
|
+
class Test::Spec::Disabled < Test::Unit::Failure # :nodoc:
|
416
|
+
def initialize(name)
|
417
|
+
@name = name
|
418
|
+
end
|
419
|
+
|
420
|
+
def single_character_display
|
421
|
+
"D"
|
422
|
+
end
|
423
|
+
|
424
|
+
def short_display
|
425
|
+
@name
|
426
|
+
end
|
427
|
+
|
428
|
+
def long_display
|
429
|
+
@name + " is disabled"
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
325
433
|
|
326
434
|
# Monkey-patch test/unit to run tests in an optionally specified order.
|
327
435
|
module Test::Unit # :nodoc:
|
@@ -346,19 +454,35 @@ module Test::Unit # :nodoc:
|
|
346
454
|
@tests.first.respond_to?(:position) ? @tests.first.position : 0
|
347
455
|
end
|
348
456
|
end
|
457
|
+
|
458
|
+
class TestResult # :nodoc:
|
459
|
+
# Records a disabled test.
|
460
|
+
def add_disabled(name)
|
461
|
+
notify_listeners(FAULT, Test::Spec::Disabled.new(name))
|
462
|
+
notify_listeners(CHANGED, self)
|
463
|
+
end
|
464
|
+
end
|
349
465
|
end
|
350
466
|
|
351
467
|
|
352
|
-
|
468
|
+
|
469
|
+
#-- Global helpers
|
353
470
|
|
354
471
|
class Object
|
355
|
-
def should
|
356
|
-
|
472
|
+
def should(*args)
|
473
|
+
case args.size
|
474
|
+
when 0
|
475
|
+
Test::Spec::Should.new(self)
|
476
|
+
when 1
|
477
|
+
Test::Spec::Should.new(self).pass(args.first)
|
478
|
+
else
|
479
|
+
raise ArgumentError, "Object#should takes zero or one argument(s)."
|
480
|
+
end
|
357
481
|
end
|
358
482
|
end
|
359
483
|
|
360
484
|
module Kernel
|
361
|
-
def context(name, &block)
|
485
|
+
def context(name, &block) # :doc:
|
362
486
|
(Test::Spec::CONTEXTS[name] ||= Test::Spec::TestCase.new(name)).add(&block)
|
363
487
|
end
|
364
488
|
|