dfect 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/MANUAL DELETED
@@ -1,23 +0,0 @@
1
- %# #%
2
- %# You can read this document in its full glory by #%
3
- %# opening ./doc/index.html in your favorite Web browser. #%
4
- %# #%
5
-
6
- % api_reference_url = 'api/index.html'
7
- % api_reference = "[API reference](#{api_reference_url})"
8
- % source_code_tool = '[Git](http://git-scm.com)'
9
- % source_code_url = 'http://github.com/sunaku/dfect'
10
- % issue_tracker_url = 'http://github.com/sunaku/dfect/issues'
11
-
12
- %|part "Welcome"
13
- %+ "README"
14
-
15
- %|part "Setup"
16
- %+ "INSTALL"
17
-
18
- %|part "Usage"
19
- %+ "USAGE"
20
-
21
- %|part "History"
22
- %|project_history
23
- %+ "HISTORY"
data/README DELETED
@@ -1,95 +0,0 @@
1
- %# #%
2
- %# You can read this document in its full glory by #%
3
- %# opening ./doc/index.html in your favorite Web browser. #%
4
- %# #%
5
-
6
- %#----------------------------------------------------------------------------
7
- %| project_summary
8
- %#----------------------------------------------------------------------------
9
-
10
- Dfect is an assertion testing library for Ruby that emphasizes a simple
11
- assertion vocabulary, instant debuggability of failures, and flexibility in
12
- composing tests.
13
-
14
- %#----------------------------------------------------------------------------
15
- %| paragraph "Resources"
16
- %#----------------------------------------------------------------------------
17
-
18
- * <%= xref "History", "What's new?" %> ---
19
- release notes and project history.
20
-
21
- * [Issue tracker](<%= issue_tracker_url %>) ---
22
- report bugs, request features, or ask for help.
23
-
24
- * [Source code](<%= source_code_url %>) ---
25
- browse online or obtain using <%= source_code_tool %>
26
-
27
- * [API reference](<%= api_reference_url %>) ---
28
- documentation for source code.
29
-
30
- * [Project home](<%= Dfect::WEBSITE %>) ---
31
- the official project home page.
32
-
33
- %#----------------------------------------------------------------------------
34
- %| section "Features"
35
- %#----------------------------------------------------------------------------
36
-
37
- Dfect is exciting because:
38
-
39
- * There are only 5 methods to remember: D F E C T.
40
-
41
- * It lets you debug assertion failures interactively.
42
-
43
- * It keeps a detailed report of assertion failures.
44
-
45
- * It lets you nest tests and execution hooks.
46
-
47
- * Its core consists of a mere <%= `sloccount lib/dfect.rb`[/^\d+/] %> lines
48
- of code.
49
-
50
- %#----------------------------------------------------------------------------
51
- %| section "Etymology"
52
- %#----------------------------------------------------------------------------
53
-
54
- Dfect is named after the D F E C T methods it provides.
55
-
56
- The name is also play on the word "defect", whereby the intentional
57
- misspelling of "defect" as "dfect" is a defect in itself! ;-)
58
-
59
- This wordplay is similar to [Mnesia][1]'s play on the word "amnesia",
60
- whereby the intentional omission of the letter "A" indicates
61
- forgetfulness---the key characteristic of having amnesia. Clever!
62
-
63
- [1]: http://www.erlang.org/doc/apps/mnesia/index.html
64
-
65
- %#----------------------------------------------------------------------------
66
- %| section "License"
67
- %#----------------------------------------------------------------------------
68
-
69
- %# See the file named "LICENSE" for details.
70
- %< "LICENSE"
71
-
72
- %#----------------------------------------------------------------------------
73
- %| section "Credits"
74
- %#----------------------------------------------------------------------------
75
-
76
- Dfect is made possible by <%= xref "History",
77
- "contributions" %> from users like you:
78
-
79
- %# See the file named "CREDITS" for details.
80
- %< "CREDITS"
81
-
82
- %#----------------------------------------------------------------------------
83
- %| section "Related works"
84
- %#----------------------------------------------------------------------------
85
-
86
- * [assert{ 2.0 }](http://assert2.rubyforge.org)
87
- * [Bacon](http://chneukirchen.org/repos/bacon/README)
88
- * [Context](http://github.com/jeremymcanally/context)
89
- * [minitest](http://blog.zenspider.com/minitest)
90
- * [RSpec](http://rspec.info)
91
- * [Shoulda](http://thoughtbot.com/projects/shoulda)
92
- * [test-spec](http://test-spec.rubyforge.org/test-spec)
93
- * [Test::Unit](http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/)
94
- * [Testy](http://github.com/ahoward/testy/tree/master)
95
- * [Verify](http://www.ruby-forum.com/topic/183354)
data/USAGE DELETED
@@ -1,406 +0,0 @@
1
- %# #%
2
- %# You can read this document in its full glory by #%
3
- %# opening ./doc/index.html in your favorite Web browser. #%
4
- %# #%
5
-
6
- %#----------------------------------------------------------------------------
7
- %| section "Shell command"
8
- %#----------------------------------------------------------------------------
9
-
10
- %|command! "dfect --help" do |node|
11
- %|text
12
- %= verbatim `ruby bin/#{node.title}`
13
-
14
- %#----------------------------------------------------------------------------
15
- %| section "Ruby library"
16
- %#----------------------------------------------------------------------------
17
-
18
- % def example_dfect_test *example_node_args, &block_containing_code_to_run
19
- % code_to_run = __block_content__(&block_containing_code_to_run).join
20
- % code_to_run.insert 0, "require 'dfect/auto'\n\n"
21
-
22
- %|example! *example_node_args
23
- When the following test is run:
24
-
25
- <%
26
- code :ruby do
27
- code_to_run
28
- end
29
- %>
30
-
31
- Dfect will output the following:
32
-
33
- <%
34
- text do
35
- IO.popen('ruby -Ilib 2>&1', 'w+') do |ruby|
36
- ruby.write code_to_run
37
- ruby.close_write
38
- ruby.read
39
- end
40
- end
41
- %>
42
-
43
- Begin by loading Dfect into your program:
44
-
45
- %|code :ruby
46
- require 'rubygems' # only necessary if you are using Ruby 1.8
47
- require 'dfect'
48
-
49
- You now have access to the `Dfect` module, which provides methods that can
50
- be either mixed-in or called directly, according to your preference:
51
-
52
- %|code :ruby
53
- Dfect.D "hello" do # D() is a class method
54
- puts "world"
55
- end
56
-
57
- # the above is same as:
58
-
59
- include Dfect # mix-in the Dfect API
60
-
61
- D "hello" do # D() is an instance method
62
- puts "world"
63
- end
64
-
65
- %#--------------------------------------------------------------------------
66
- %| section "Assertions"
67
- %#--------------------------------------------------------------------------
68
-
69
- The following methods accept a block parameter and assert something about
70
- the result of executing that block. They also accept an optional message,
71
- which is shown in <%= xref "Failures", "failure reports" %> if they fail.
72
-
73
- See the <%= api_reference %> for more details and examples.
74
-
75
- %|table
76
- %|thead
77
- %|tr
78
- %|th
79
- Method
80
- %|th
81
- Description
82
- %|tbody
83
- %|tr
84
- %|td
85
- T
86
- %|td
87
- assert true (not `nil` and not `false`)
88
- %|tr
89
- %|td
90
- F
91
- %|td
92
- assert not true (`nil` or `false`)
93
- %|tr
94
- %|td
95
- E
96
- %|td
97
- assert that an execption is raised
98
- %|tr
99
- %|td
100
- C
101
- %|td
102
- assert that a symbol is thrown
103
-
104
- %#------------------------------------------------------------------------
105
- %| section "Negation"
106
- %#------------------------------------------------------------------------
107
-
108
- These methods are the *opposite* of
109
- <%= xref "Assertions", "normal assertions" %>.
110
-
111
- %|table
112
- %|thead
113
- %|tr
114
- %|th
115
- Method
116
- %|th
117
- Description
118
- %|tbody
119
- %|tr
120
- %|td
121
- T!
122
- %|td
123
- same as F
124
- %|tr
125
- %|td
126
- F!
127
- %|td
128
- same as T
129
- %|tr
130
- %|td
131
- E!
132
- %|td
133
- assert that an exception is *not* raised
134
- %|tr
135
- %|td
136
- C!
137
- %|td
138
- assert that a symbol is *not* thrown
139
-
140
- %#------------------------------------------------------------------------
141
- %| section "Sampling"
142
- %#------------------------------------------------------------------------
143
-
144
- These methods allow you to *check the outcome* of an assertion without
145
- recording a success or failure for that assertion in the execution
146
- report.
147
-
148
- %|table
149
- %|thead
150
- %|tr
151
- %|th
152
- Method
153
- %|th
154
- Description
155
- %|tbody
156
- %|tr
157
- %|td
158
- T?
159
- %|td
160
- returns `true` if T passes; `false` otherwise
161
- %|tr
162
- %|td
163
- F?
164
- %|td
165
- returns `true` if F passes; `false` otherwise
166
- %|tr
167
- %|td
168
- E?
169
- %|td
170
- returns `true` if E passes; `false` otherwise
171
- %|tr
172
- %|td
173
- C?
174
- %|td
175
- returns `true` if C passes; `false` otherwise
176
-
177
- %#------------------------------------------------------------------------
178
- %| section "Failures"
179
- %#------------------------------------------------------------------------
180
-
181
- When an assertion fails, details about the failure will be shown:
182
-
183
- - fail: block must yield true (!nil && !false)
184
- code: |-
185
- [12..22] in test/simple.rb
186
- 12
187
- 13 D "with more nested tests" do
188
- 14 x = 5
189
- 15
190
- 16 T { x > 2 } # passes
191
- => 17 F { x > 2 } # fails
192
- 18 E { x.hello } # passes
193
- 19 end
194
- 20 end
195
- 21
196
- 22 # equivalent of before(:each) or setup()
197
- vars:
198
- x: 5
199
- y: 83
200
- call:
201
- - test/simple.rb:17
202
- - test/simple.rb:3
203
-
204
- You will then be placed into a debugger to investigate the failure if
205
- the `:debug` option is enabled in the `Dfect.options` hash.
206
-
207
- Details about all assertion failures and a trace of all tests executed
208
- are stored by Dfect and provided by the `Dfect.report()` method.
209
-
210
- %#------------------------------------------------------------------------
211
- %| section "Emulation"
212
- %#------------------------------------------------------------------------
213
-
214
- Dfect provides emulation layers for several popular testing libraries:
215
-
216
- * <tt>dfect/unit</tt> --- Test::Unit
217
- * <tt>dfect/mini</tt> --- Minitest
218
- * <tt>dfect/spec</tt> --- RSpec
219
-
220
- Simply `require()` one of these emulation layers into your test suite
221
- and you can write your tests using the familiar syntax of that testing
222
- library. See [their source code](<%= source_code_url
223
- %>/tree/master/lib/dfect/) for more details.
224
-
225
- %#--------------------------------------------------------------------------
226
- %| section "Tests"
227
- %#--------------------------------------------------------------------------
228
-
229
- The `D()` method defines a new Dfect **test**, which is analagous to the
230
- concept of **test case** in xUnit or **describe** in rSpec. A test may
231
- contain nested tests.
232
-
233
- %|code :ruby
234
- D "outer test" do
235
- # assertions and logic here
236
-
237
- D "inner test" do
238
- # more assertions and logic here
239
- end
240
- end
241
-
242
- %#------------------------------------------------------------------------
243
- %| section "Execution"
244
- %#------------------------------------------------------------------------
245
-
246
- Tests are executed in depth-first order.
247
-
248
- You can configure the test execution process using:
249
-
250
- %|code :ruby
251
- Dfect.options = your_options_hash
252
-
253
- You can execute all tests defined thus far using:
254
-
255
- %|code :ruby
256
- Dfect.run
257
-
258
- You can stop the execution at any time using:
259
-
260
- %|code :ruby
261
- Dfect.stop
262
-
263
- You can view the results of execution using:
264
-
265
- %|code :ruby
266
- puts Dfect.report.to_yaml
267
-
268
- See the <%= api_reference %> for details and examples.
269
-
270
- %#----------------------------------------------------------------------
271
- %| paragraph "Automatic test execution"
272
- %#----------------------------------------------------------------------
273
-
274
- To mix-in the `Dfect` module into your program and execute all tests
275
- defined by your program before it terminates, simply add the following
276
- line at the top of your program:
277
-
278
- %|code :ruby
279
- require 'dfect/auto'
280
-
281
- %#----------------------------------------------------------------------
282
- %| section "Hooks"
283
- %#----------------------------------------------------------------------
284
-
285
- The `D()` method provides several entry points (hooks) into the test
286
- execution process:
287
-
288
- %|code :ruby
289
- D "outer test" do
290
- D .< { puts "before each nested test" }
291
- D .> { puts "after each nested test" }
292
- D .<< { puts "before all nested tests" }
293
- D .>> { puts "after all nested tests" }
294
-
295
- D "inner test" do
296
- # assertions and logic here
297
- end
298
- end
299
-
300
- A hook method may be called multiple times. Each call registers
301
- additional logic to execute during the hook:
302
-
303
- %|code :ruby
304
- D .< { puts "do something" }
305
- D .< { puts "do something more!" }
306
-
307
- %#----------------------------------------------------------------------
308
- %| section "Logging"
309
- %#----------------------------------------------------------------------
310
-
311
- The `L()` method lets you insert log messages, composed of arbitrary
312
- Ruby objects, into the test execution report.
313
-
314
- %|example_dfect_test "Logging information in the execution report"
315
- D 'Wizard' do
316
- L 'Preparing spell to defeat mortal foes...'
317
- end
318
-
319
- D 'Magician' do
320
- L 'Preparing rabbits to pull from hat...', rand(15)
321
- end
322
-
323
- D 'Calculator' do
324
- L Math::PI, [1, 2, 3, ['a', 'b', 'c']], {:foo => 'bar!'}
325
- end
326
-
327
- %#------------------------------------------------------------------------
328
- %| section "Sharing"
329
- %#------------------------------------------------------------------------
330
-
331
- The `S()` method is a mechanism for sharing code. When called with a
332
- block, it shares the given block (under a given identifier) for
333
- injection into other tests. When called without a block, it injects a
334
- previously shared block (under a given identifier) into the environment
335
- where it is called.
336
-
337
- The `S!()` method is a combination of the two uses of the `S()` method:
338
- it lets you simultaneously share a block of code while injecting it into
339
- the environment where that method is called.
340
-
341
- The `S?()` method simply checks whether any code has been shared under a
342
- given identifier.
343
-
344
- %|example_dfect_test "Sharing code between tests"
345
- S :knowledge do
346
- L 'Knowledge is power!'
347
- end
348
-
349
- D 'Healer' do
350
- S :knowledge
351
- end
352
-
353
- D 'Warrior' do
354
- S! :strength do
355
- L 'Strength is power!'
356
- end
357
- end
358
-
359
- D 'Wizard' do
360
- S :knowledge
361
- S :strength
362
- end
363
-
364
- D 'King' do
365
- T { S? :knowledge }
366
- T { S? :strength }
367
- F { S? :power }
368
- L 'Power is power!'
369
- end
370
-
371
- %#------------------------------------------------------------------------
372
- %| section "Insulation"
373
- %#------------------------------------------------------------------------
374
-
375
- The `D!()` method defines a new test that is explicitly insulated from
376
- the tests that contain it and also from the top-level Ruby environment.
377
- Root-level calls to the `D()` method are insulated by default.
378
-
379
- Inside an insulated test, you are free to:
380
- * mix-in any modules your test logic needs
381
- * define your own constants, methods, and classes
382
-
383
- %|example_dfect_test "Insulated and uninsulated tests"
384
- D "a root-level test" do
385
- @outside = 1
386
- T { defined? @outside }
387
- T { @outside == 1 }
388
-
389
- D "an inner, non-insulated test" do
390
- T { defined? @outside }
391
- T { @outside == 1 }
392
- end
393
-
394
- D! "an inner, insulated test" do
395
- F { defined? @outside }
396
- F { @outside == 1 }
397
-
398
- @inside = 2
399
- T { defined? @inside }
400
- T { @inside == 2 }
401
- end
402
-
403
- F { defined? @inside }
404
- F { @inside == 2 }
405
- end
406
-