dfect 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CREDITS +2 -2
  2. data/HISTORY +306 -0
  3. data/INSTALL +35 -0
  4. data/README +95 -0
  5. data/USAGE +393 -0
  6. data/doc/api/Dfect.html +3179 -0
  7. data/doc/api/Object.html +107 -0
  8. data/doc/api/_index.html +107 -0
  9. data/doc/api/class_list.html +36 -0
  10. data/doc/api/css/common.css +1 -0
  11. data/doc/api/css/full_list.css +50 -0
  12. data/doc/api/css/style.css +268 -0
  13. data/doc/api/file.LICENSE.html +73 -0
  14. data/doc/api/file_list.html +38 -0
  15. data/doc/api/frames.html +13 -0
  16. data/doc/api/index.html +72 -13
  17. data/doc/api/js/app.js +99 -0
  18. data/doc/api/js/full_list.js +106 -0
  19. data/doc/api/js/{jquery-1.3.2.min.js → jquery.js} +0 -0
  20. data/doc/api/method_list.html +339 -0
  21. data/doc/api/top-level-namespace.html +87 -0
  22. data/doc/index.erb +16 -9
  23. data/doc/index.html +1057 -726
  24. data/lib/dfect.rb +431 -284
  25. data/lib/dfect/auto.rb +2 -6
  26. data/lib/dfect/inochi.rb +48 -0
  27. data/lib/dfect/inochi.yaml +75 -0
  28. data/lib/dfect/mini.rb +1 -5
  29. data/lib/dfect/spec.rb +6 -13
  30. data/lib/dfect/unit.rb +21 -33
  31. data/test/dfect/inochi_test.rb +17 -0
  32. data/test/{dfect.rb → dfect_test.rb} +167 -7
  33. data/test/runner +25 -0
  34. data/test/test_helper.rb +1 -0
  35. metadata +43 -55
  36. data/doc/api/apple-touch-icon.png +0 -0
  37. data/doc/api/classes/Class.html +0 -73
  38. data/doc/api/classes/Dfect.html +0 -1245
  39. data/doc/api/classes/Kernel.html +0 -322
  40. data/doc/api/classes/Object.html +0 -72
  41. data/doc/api/created.rid +0 -1
  42. data/doc/api/css/main.css +0 -263
  43. data/doc/api/css/panel.css +0 -383
  44. data/doc/api/css/reset.css +0 -53
  45. data/doc/api/favicon.ico +0 -0
  46. data/doc/api/files/CREDITS.html +0 -65
  47. data/doc/api/files/LICENSE.html +0 -76
  48. data/doc/api/files/lib/dfect/auto_rb.html +0 -80
  49. data/doc/api/files/lib/dfect/mini_rb.html +0 -77
  50. data/doc/api/files/lib/dfect/spec_rb.html +0 -73
  51. data/doc/api/files/lib/dfect/unit_rb.html +0 -73
  52. data/doc/api/files/lib/dfect_rb.html +0 -74
  53. data/doc/api/i/arrows.png +0 -0
  54. data/doc/api/i/results_bg.png +0 -0
  55. data/doc/api/i/tree_bg.png +0 -0
  56. data/doc/api/js/jquery-effect.js +0 -593
  57. data/doc/api/js/main.js +0 -22
  58. data/doc/api/js/searchdoc.js +0 -628
  59. data/doc/api/panel/index.html +0 -71
  60. data/doc/api/panel/search_index.js +0 -1
  61. data/doc/api/panel/tree.js +0 -1
  62. data/doc/history.erb +0 -161
  63. data/doc/intro.erb +0 -104
  64. data/doc/setup.erb +0 -107
  65. data/doc/usage.erb +0 -310
  66. data/rakefile +0 -21
data/test/runner ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Adds the project library directory
4
+ # and this test directory to Ruby's
5
+ # load path and runs the given tests.
6
+ #
7
+ # Usage: ruby test/runner [TESTS_TO_RUN]
8
+ #
9
+ # Where: TESTS_TO_RUN is a list of files
10
+ # or file globbing patterns that
11
+ # describe a set of files to run.
12
+ #
13
+ # If this parameter is not given,
14
+ # all *_test.rb files within or
15
+ # beneath this directory are run.
16
+
17
+ lib_dir = File.expand_path('../../lib', __FILE__)
18
+ test_dir = File.expand_path('..', __FILE__)
19
+ $LOAD_PATH.unshift lib_dir, test_dir
20
+
21
+ require 'dfect/inochi'
22
+ require 'test_helper'
23
+
24
+ ARGV << "#{test_dir}/**/*_test.rb" if ARGV.empty?
25
+ ARGV.each {|glob| Dir[glob].each {|test| load test } }
@@ -0,0 +1 @@
1
+ require 'dfect/auto'
metadata CHANGED
@@ -1,31 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dfect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
5
10
  platform: ruby
6
11
  authors:
7
- - Suraj N. Kurapati
12
+ - Suraj N. Kurapati <sunaku@gmail.com>
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-10-27 00:00:00 -07:00
17
+ date: 2010-03-21 00:00:00 -07:00
13
18
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: inochi
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: "1"
24
- version:
25
- description: " Dfect 1.1.0\n\n Assertion testing library for Ruby\n\n http://snk.tuxfamily.org/lib/dfect/\n\n Dfect is an assertion testing library for Ruby that\n emphasizes a simple assertion vocabulary, instant\n debuggability of failures, and flexibility in composing\n tests.\n\n\
26
- Version 1.1.0 (2009-10-27)\n\n This release adds a new method for emitting status messages\n and does some internal housekeeping.\n\n * [1]Thank you\n\n * [2]New features\n\n * [3]Housekeeping\n\n Thank you\n\n * I\xC3\xB1aki Baz Castillo used Dfect and suggested new\n features.\n\n New features\n\n * Add Dfect::S() method for [4]adding status messages to\n the execution report. This feature was [5]requested by\n I\xC3\xB1aki Baz Castillo.\n\n Housekeeping\n\n * Remove unused require of `delegate' standard library in\n `dfect/spec' RSpec emulation layer.\n\n * Mention [6]Emulation layers for popular testing\n libraries.\n\n * Mention that assertions take an optional message\n parameter.\n\n * Replace sample unit test with Dfect test suite.\n\n * Upgrade user manual to ERBook 9.0.0.\n\n\
27
- References\n\n 1. http://snk.tuxfamily.org/lib/dfect/#Thank-you\n 2. http://snk.tuxfamily.org/lib/dfect/#New-features\n 3. http://snk.tuxfamily.org/lib/dfect/#Housekeeping\n 4. http://snk.tuxfamily.org/lib/dfect/#Reporting\n 5. http://github.com/sunaku/dfect/issues/closed#issue/1\n 6. http://snk.tuxfamily.org/lib/dfect/#Emulation\n"
28
- email: sunaku@gmail.com
19
+ dependencies: []
20
+
21
+ description: " Dfect is an assertion testing library for Ruby that\n emphasizes a simple assertion vocabulary, instant\n debuggability of failures, and flexibility in composing\n tests.\n"
22
+ email:
29
23
  executables: []
30
24
 
31
25
  extensions: []
@@ -34,47 +28,39 @@ extra_rdoc_files: []
34
28
 
35
29
  files:
36
30
  - CREDITS
37
- - rakefile
38
- - test/dfect.rb
31
+ - INSTALL
32
+ - test/runner
33
+ - test/dfect/inochi_test.rb
34
+ - test/test_helper.rb
35
+ - test/dfect_test.rb
36
+ - lib/dfect/inochi.rb
39
37
  - lib/dfect/auto.rb
38
+ - lib/dfect/inochi.yaml
40
39
  - lib/dfect/mini.rb
41
40
  - lib/dfect/unit.rb
42
41
  - lib/dfect/spec.rb
43
42
  - lib/dfect.rb
43
+ - USAGE
44
44
  - LICENSE
45
- - doc/intro.erb
46
- - doc/setup.erb
45
+ - HISTORY
46
+ - README
47
47
  - doc/index.html
48
- - doc/api/classes/Class.html
49
- - doc/api/classes/Object.html
50
- - doc/api/classes/Kernel.html
51
- - doc/api/classes/Dfect.html
52
- - doc/api/panel/search_index.js
53
- - doc/api/panel/tree.js
54
- - doc/api/panel/index.html
55
- - doc/api/js/searchdoc.js
56
- - doc/api/js/jquery-effect.js
57
- - doc/api/js/jquery-1.3.2.min.js
58
- - doc/api/js/main.js
59
- - doc/api/files/CREDITS.html
60
- - doc/api/files/LICENSE.html
61
- - doc/api/files/lib/dfect_rb.html
62
- - doc/api/files/lib/dfect/spec_rb.html
63
- - doc/api/files/lib/dfect/auto_rb.html
64
- - doc/api/files/lib/dfect/unit_rb.html
65
- - doc/api/files/lib/dfect/mini_rb.html
66
- - doc/api/css/main.css
67
- - doc/api/css/reset.css
68
- - doc/api/css/panel.css
69
- - doc/api/i/arrows.png
70
- - doc/api/i/tree_bg.png
71
- - doc/api/i/results_bg.png
72
- - doc/api/apple-touch-icon.png
73
- - doc/api/created.rid
74
- - doc/api/favicon.ico
48
+ - doc/api/class_list.html
49
+ - doc/api/js/full_list.js
50
+ - doc/api/js/jquery.js
51
+ - doc/api/js/app.js
52
+ - doc/api/method_list.html
53
+ - doc/api/css/full_list.css
54
+ - doc/api/css/style.css
55
+ - doc/api/css/common.css
56
+ - doc/api/Object.html
57
+ - doc/api/_index.html
58
+ - doc/api/frames.html
59
+ - doc/api/top-level-namespace.html
75
60
  - doc/api/index.html
76
- - doc/usage.erb
77
- - doc/history.erb
61
+ - doc/api/Dfect.html
62
+ - doc/api/file.LICENSE.html
63
+ - doc/api/file_list.html
78
64
  - doc/index.erb
79
65
  has_rdoc: true
80
66
  homepage: http://snk.tuxfamily.org/lib/dfect/
@@ -89,18 +75,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
75
  requirements:
90
76
  - - ">="
91
77
  - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
92
80
  version: "0"
93
- version:
94
81
  required_rubygems_version: !ruby/object:Gem::Requirement
95
82
  requirements:
96
83
  - - ">="
97
84
  - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
98
87
  version: "0"
99
- version:
100
88
  requirements: []
101
89
 
102
- rubyforge_project: sunaku
103
- rubygems_version: 1.3.5
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.6
104
92
  signing_key:
105
93
  specification_version: 3
106
94
  summary: Assertion testing library for Ruby
Binary file
@@ -1,73 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <title>Class</title>
7
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
- <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
9
- <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
10
- <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
11
- <script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
12
- <script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
13
- </head>
14
-
15
- <body>
16
- <div class="banner">
17
- <h1>
18
- <span class="type">Class</span>
19
- Class
20
-
21
- <span class="parent">&lt;
22
-
23
- <a href="Object.html">Object</a>
24
-
25
- </span>
26
-
27
- </h1>
28
- <ul class="files">
29
-
30
- <li><a href="../files/lib/dfect_rb.html">lib/dfect.rb</a></li>
31
-
32
- </ul>
33
- </div>
34
- <div id="bodyContent">
35
- <div id="content">
36
-
37
- <div class="description">
38
- <p>
39
- YAML raises this error when we try to serialize a class:
40
- </p>
41
- <pre>
42
- TypeError: can't dump anonymous class Class
43
- </pre>
44
- <p>
45
- Work around this by representing a class by its name.
46
- </p>
47
-
48
- </div>
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
- </div>
71
- </div>
72
- </body>
73
- </html>
@@ -1,1245 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <title>Dfect</title>
7
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
- <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
9
- <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
10
- <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
11
- <script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
12
- <script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
13
- </head>
14
-
15
- <body>
16
- <div class="banner">
17
- <h1>
18
- <span class="type">Module</span>
19
- Dfect
20
-
21
- </h1>
22
- <ul class="files">
23
-
24
- <li><a href="../files/lib/dfect_rb.html">lib/dfect.rb</a></li>
25
-
26
- </ul>
27
- </div>
28
- <div id="bodyContent">
29
- <div id="content">
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
- <div class="sectiontitle">Methods</div>
40
- <dl class="methods">
41
-
42
- <dt>#</dt>
43
- <dd>
44
- <ul>
45
-
46
- <li><a href="#M000008"><</a>,</li>
47
-
48
- <li><a href="#M000010"><<</a>,</li>
49
-
50
- <li><a href="#M000009">></a>,</li>
51
-
52
- <li><a href="#M000011">>></a></li>
53
-
54
- </ul>
55
- </dd>
56
-
57
- <dt>C</dt>
58
- <dd>
59
- <ul>
60
-
61
- <li><a href="#M000019">C</a>,</li>
62
-
63
- <li><a href="#M000020">C!</a>,</li>
64
-
65
- <li><a href="#M000021">C?</a></li>
66
-
67
- </ul>
68
- </dd>
69
-
70
- <dt>D</dt>
71
- <dd>
72
- <ul>
73
-
74
- <li><a href="#M000007">D</a></li>
75
-
76
- </ul>
77
- </dd>
78
-
79
- <dt>E</dt>
80
- <dd>
81
- <ul>
82
-
83
- <li><a href="#M000016">E</a>,</li>
84
-
85
- <li><a href="#M000017">E!</a>,</li>
86
-
87
- <li><a href="#M000018">E?</a></li>
88
-
89
- </ul>
90
- </dd>
91
-
92
- <dt>F</dt>
93
- <dd>
94
- <ul>
95
-
96
- <li><a href="#M000015">F?</a></li>
97
-
98
- </ul>
99
- </dd>
100
-
101
- <dt>S</dt>
102
- <dd>
103
- <ul>
104
-
105
- <li><a href="#M000022">S</a></li>
106
-
107
- </ul>
108
- </dd>
109
-
110
- <dt>T</dt>
111
- <dd>
112
- <ul>
113
-
114
- <li><a href="#M000012">T</a>,</li>
115
-
116
- <li><a href="#M000013">T!</a>,</li>
117
-
118
- <li><a href="#M000014">T?</a></li>
119
-
120
- </ul>
121
- </dd>
122
-
123
- <dt>R</dt>
124
- <dd>
125
- <ul>
126
-
127
- <li><a href="#M000023">run</a></li>
128
-
129
- </ul>
130
- </dd>
131
-
132
- <dt>S</dt>
133
- <dd>
134
- <ul>
135
-
136
- <li><a href="#M000024">stop</a></li>
137
-
138
- </ul>
139
- </dd>
140
-
141
- </dl>
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
- <div class="sectiontitle">Constants</div>
152
- <table border='0' cellpadding='5'>
153
-
154
- <tr valign='top'>
155
- <td class="attr-name">D</td>
156
- <td>=</td>
157
- <td class="attr-value">self</td>
158
- </tr>
159
-
160
- <tr valign='top'>
161
- <td>&nbsp;</td>
162
- <td colspan="2" class="attr-desc"><p>
163
- Allows before and after hooks to be specified via the D() method syntax
164
- when this module is mixed-in:
165
- </p>
166
- <pre>
167
- D .&lt;&lt; { puts &quot;before all nested tests&quot; }
168
- D .&lt; { puts &quot;before each nested test&quot; }
169
- D .&gt; { puts &quot;after each nested test&quot; }
170
- D .&gt;&gt; { puts &quot;after all nested tests&quot; }
171
- </pre>
172
- </td>
173
- </tr>
174
-
175
-
176
- </table>
177
-
178
-
179
-
180
- <div class="sectiontitle">Attributes</div>
181
- <table border='0' cellpadding='5'>
182
-
183
- <tr valign='top'>
184
- <td class='attr-rw'>
185
- [R]
186
- </td>
187
- <td class='attr-name'>report</td>
188
- <td class='attr-desc'><p>
189
- Hash of test results, assembled by <a href="Dfect.html#M000023">run</a>.
190
- </p>
191
- <dl>
192
- <dt>:execution</dt><dd>Hierarchical trace of all tests executed, where each test is represented by
193
- its description, is mapped to an Array of nested tests, and may contain
194
- zero or more assertion failures.
195
-
196
- <p>
197
- Assertion failures are represented as a Hash:
198
- </p>
199
- <dl>
200
- <dt>&#8220;fail&#8220;</dt><dd>Description of the assertion failure.
201
-
202
- </dd>
203
- <dt>&#8220;code&#8220;</dt><dd>Source code surrounding the point of failure.
204
-
205
- </dd>
206
- <dt>&#8220;vars&#8220;</dt><dd>Local variables visible at the point of failure.
207
-
208
- </dd>
209
- <dt>&#8220;call&#8220;</dt><dd>Stack trace leading to the point of failure.
210
-
211
- </dd>
212
- </dl>
213
- </dd>
214
- <dt>:statistics</dt><dd>Hash of counts of major events in test execution:
215
-
216
- <dl>
217
- <dt>:passed_assertions</dt><dd>Number of assertions that held true.
218
-
219
- </dd>
220
- <dt>:failed_assertions</dt><dd>Number of assertions that did not hold true.
221
-
222
- </dd>
223
- <dt>:uncaught_exceptions</dt><dd>Number of exceptions that were not rescued.
224
-
225
- </dd>
226
- </dl>
227
- </dd>
228
- </dl></td>
229
- </tr>
230
-
231
- <tr valign='top'>
232
- <td class='attr-rw'>
233
- [RW]
234
- </td>
235
- <td class='attr-name'>options</td>
236
- <td class='attr-desc'><p>
237
- Hash of choices that affect how <a href="Dfect.html">Dfect</a> operates.
238
- </p>
239
- <dl>
240
- <dt>:debug</dt><dd>Launch an interactive debugger during assertion failures so the user can
241
- investigate them.
242
-
243
- <p>
244
- The default value is true.
245
- </p>
246
- </dd>
247
- <dt>:quiet</dt><dd>Do not print the report after executing all tests.
248
-
249
- <p>
250
- The default value is false.
251
- </p>
252
- </dd>
253
- </dl></td>
254
- </tr>
255
-
256
- </table>
257
-
258
-
259
-
260
- <div class="sectiontitle">Class Public methods</div>
261
-
262
- <div class="method">
263
- <div class="title" id="M000008">
264
-
265
- <a name="M000008"></a><b> <(&block)
266
- </b>
267
-
268
- </div>
269
-
270
- <div class="description">
271
- <p>
272
- Registers the given block to be executed before each nested test inside
273
- this test.
274
- </p>
275
- <h4>Examples</h4>
276
- <pre>
277
- D .&lt; { puts &quot;before each nested test&quot; }
278
-
279
- D .&lt; do
280
- puts &quot;before each nested test&quot;
281
- end
282
- </pre>
283
-
284
- </div>
285
-
286
-
287
-
288
-
289
- <div class="sourcecode">
290
- <p class="source-link">
291
- Source: <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show</a>
292
-
293
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L146" target="_blank" class="github_url">on GitHub</a>
294
-
295
- </p>
296
- <div id="M000008_source" class="dyn-source">
297
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 146</span>
298
- <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
299
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
300
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'block must be given'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
301
- <span class="ruby-ivar">@curr_suite</span>.<span class="ruby-identifier">before_each</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span>
302
- <span class="ruby-keyword kw">else</span>
303
- <span class="ruby-comment cmt"># the &lt; method is being used as a check for inheritance</span>
304
- <span class="ruby-keyword kw">super</span>
305
- <span class="ruby-keyword kw">end</span>
306
- <span class="ruby-keyword kw">end</span></pre>
307
- </div>
308
- </div>
309
-
310
- </div>
311
-
312
- <div class="method">
313
- <div class="title" id="M000010">
314
-
315
- <a name="M000010"></a><b>&lt;&lt;</b>(&amp;block)
316
-
317
- </div>
318
-
319
- <div class="description">
320
- <p>
321
- Registers the given block to be executed before all nested tests inside
322
- this test.
323
- </p>
324
- <h4>Examples</h4>
325
- <pre>
326
- D .&lt;&lt; { puts &quot;before all nested tests&quot; }
327
-
328
- D .&lt;&lt; do
329
- puts &quot;before all nested tests&quot;
330
- end
331
- </pre>
332
-
333
- </div>
334
-
335
-
336
-
337
-
338
- <div class="sourcecode">
339
- <p class="source-link">
340
- Source: <a href="javascript:toggleSource('M000010_source')" id="l_M000010_source">show</a>
341
-
342
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L185" target="_blank" class="github_url">on GitHub</a>
343
-
344
- </p>
345
- <div id="M000010_source" class="dyn-source">
346
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 185</span>
347
- <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
348
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'block must be given'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
349
- <span class="ruby-ivar">@curr_suite</span>.<span class="ruby-identifier">before_all</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span>
350
- <span class="ruby-keyword kw">end</span></pre>
351
- </div>
352
- </div>
353
-
354
- </div>
355
-
356
- <div class="method">
357
- <div class="title" id="M000009">
358
-
359
- <a name="M000009"></a><b>&gt;</b>(&amp;block)
360
-
361
- </div>
362
-
363
- <div class="description">
364
- <p>
365
- Registers the given block to be executed after each nested test inside this
366
- test.
367
- </p>
368
- <h4>Examples</h4>
369
- <pre>
370
- D .&gt; { puts &quot;after each nested test&quot; }
371
-
372
- D .&gt; do
373
- puts &quot;after each nested test&quot;
374
- end
375
- </pre>
376
-
377
- </div>
378
-
379
-
380
-
381
-
382
- <div class="sourcecode">
383
- <p class="source-link">
384
- Source: <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show</a>
385
-
386
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L168" target="_blank" class="github_url">on GitHub</a>
387
-
388
- </p>
389
- <div id="M000009_source" class="dyn-source">
390
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 168</span>
391
- <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
392
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'block must be given'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
393
- <span class="ruby-ivar">@curr_suite</span>.<span class="ruby-identifier">after_each</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span>
394
- <span class="ruby-keyword kw">end</span></pre>
395
- </div>
396
- </div>
397
-
398
- </div>
399
-
400
- <div class="method">
401
- <div class="title" id="M000011">
402
-
403
- <a name="M000011"></a><b>&gt;&gt;</b>(&amp;block)
404
-
405
- </div>
406
-
407
- <div class="description">
408
- <p>
409
- Registers the given block to be executed after all nested tests inside this
410
- test.
411
- </p>
412
- <h4>Examples</h4>
413
- <pre>
414
- D .&gt;&gt; { puts &quot;after all nested tests&quot; }
415
-
416
- D .&gt;&gt; do
417
- puts &quot;after all nested tests&quot;
418
- end
419
- </pre>
420
-
421
- </div>
422
-
423
-
424
-
425
-
426
- <div class="sourcecode">
427
- <p class="source-link">
428
- Source: <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show</a>
429
-
430
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L202" target="_blank" class="github_url">on GitHub</a>
431
-
432
- </p>
433
- <div id="M000011_source" class="dyn-source">
434
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 202</span>
435
- <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
436
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'block must be given'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
437
- <span class="ruby-ivar">@curr_suite</span>.<span class="ruby-identifier">after_all</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span>
438
- <span class="ruby-keyword kw">end</span></pre>
439
- </div>
440
- </div>
441
-
442
- </div>
443
-
444
- <div class="method">
445
- <div class="title" id="M000019">
446
-
447
- <a name="M000019"></a><b>C</b>(message = nil, symbol = nil, &amp;block)
448
-
449
- </div>
450
-
451
- <div class="description">
452
- <p>
453
- Asserts that the given symbol is thrown when the given block is executed.
454
- </p>
455
- <p>
456
- If a value is thrown along with the expected symbol, then that value is
457
- returned.
458
- </p>
459
- <p>
460
- Otherwise, nil is returned.
461
- </p>
462
- <h4>Parameters</h4>
463
- <dl>
464
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
465
-
466
- </dd>
467
- <dt>symbol</dt><dd>Symbol that must be thrown by the given block.
468
-
469
- </dd>
470
- </dl>
471
- <h4>Examples</h4>
472
- <pre>
473
- # no message specified:
474
-
475
- C(:foo) { throw :foo, 123 } # passes, =&gt; 123
476
- C(:foo) { throw :bar, 456 } # fails, =&gt; 456
477
- C(:foo) { } # fails, =&gt; nil
478
-
479
- # message specified:
480
-
481
- C( &quot;:foo must be thrown&quot;, :foo ) { throw :bar, 789 } # fails, =&gt; nil
482
- </pre>
483
-
484
- </div>
485
-
486
-
487
-
488
-
489
- <div class="sourcecode">
490
- <p class="source-link">
491
- Source: <a href="javascript:toggleSource('M000019_source')" id="l_M000019_source">show</a>
492
-
493
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L464" target="_blank" class="github_url">on GitHub</a>
494
-
495
- </p>
496
- <div id="M000019_source" class="dyn-source">
497
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 464</span>
498
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">C</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">symbol</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
499
- <span class="ruby-identifier">assert_catch</span> <span class="ruby-identifier">:assert</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
500
- <span class="ruby-keyword kw">end</span></pre>
501
- </div>
502
- </div>
503
-
504
- </div>
505
-
506
- <div class="method">
507
- <div class="title" id="M000020">
508
-
509
- <a name="M000020"></a><b>C!</b>(message = nil, symbol = nil, &amp;block)
510
-
511
- </div>
512
-
513
- <div class="description">
514
- <p>
515
- Asserts that the given symbol is not thrown when the given block is
516
- executed.
517
- </p>
518
- <p>
519
- Returns nil, always.
520
- </p>
521
- <h4>Parameters</h4>
522
- <dl>
523
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
524
-
525
- </dd>
526
- <dt>symbol</dt><dd>Symbol that must not be thrown by the given block.
527
-
528
- </dd>
529
- </dl>
530
- <h4>Examples</h4>
531
- <pre>
532
- # no message specified:
533
-
534
- C!(:foo) { throw :foo, 123 } # fails, =&gt; nil
535
- C!(:foo) { throw :bar, 456 } # passes, =&gt; nil
536
- C!(:foo) { } # passes, =&gt; nil
537
-
538
- # message specified:
539
-
540
- C!( &quot;:foo must be thrown&quot;, :foo ) { throw :bar, 789 } # passes, =&gt; nil
541
- </pre>
542
-
543
- </div>
544
-
545
-
546
-
547
-
548
- <div class="sourcecode">
549
- <p class="source-link">
550
- Source: <a href="javascript:toggleSource('M000020_source')" id="l_M000020_source">show</a>
551
-
552
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L495" target="_blank" class="github_url">on GitHub</a>
553
-
554
- </p>
555
- <div id="M000020_source" class="dyn-source">
556
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 495</span>
557
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">C!</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">symbol</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
558
- <span class="ruby-identifier">assert_catch</span> <span class="ruby-identifier">:negate</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
559
- <span class="ruby-keyword kw">end</span></pre>
560
- </div>
561
- </div>
562
-
563
- </div>
564
-
565
- <div class="method">
566
- <div class="title" id="M000021">
567
-
568
- <a name="M000021"></a><b>C?</b>(message = nil, symbol = nil, &amp;block)
569
-
570
- </div>
571
-
572
- <div class="description">
573
- <p>
574
- Returns true if the given symbol is thrown when the given block is
575
- executed. Otherwise, returns false.
576
- </p>
577
- <h4>Parameters</h4>
578
- <dl>
579
- <dt>message</dt><dd>This parameter is optional and completely ignored.
580
-
581
- </dd>
582
- <dt>symbol</dt><dd>Symbol that must be thrown by the given block.
583
-
584
- </dd>
585
- </dl>
586
- <h4>Examples</h4>
587
- <pre>
588
- # no message specified:
589
-
590
- C?(:foo) { throw :foo, 123 } # =&gt; true
591
- C?(:foo) { throw :bar, 456 } # =&gt; false
592
- C?(:foo) { } # =&gt; false
593
-
594
- # message specified:
595
-
596
- C?( &quot;:foo must be thrown&quot;, :foo ) { throw :bar, 789 } # =&gt; false
597
- </pre>
598
-
599
- </div>
600
-
601
-
602
-
603
-
604
- <div class="sourcecode">
605
- <p class="source-link">
606
- Source: <a href="javascript:toggleSource('M000021_source')" id="l_M000021_source">show</a>
607
-
608
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L523" target="_blank" class="github_url">on GitHub</a>
609
-
610
- </p>
611
- <div id="M000021_source" class="dyn-source">
612
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 523</span>
613
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">C?</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">symbol</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
614
- <span class="ruby-identifier">assert_catch</span> <span class="ruby-identifier">:sample</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">symbol</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
615
- <span class="ruby-keyword kw">end</span></pre>
616
- </div>
617
- </div>
618
-
619
- </div>
620
-
621
- <div class="method">
622
- <div class="title" id="M000007">
623
-
624
- <a name="M000007"></a><b>D</b>(description = caller.first, &amp;block)
625
-
626
- </div>
627
-
628
- <div class="description">
629
- <p>
630
- Defines a new test, composed of the given description and the given block
631
- to execute.
632
- </p>
633
- <p>
634
- A test may contain nested tests.
635
- </p>
636
- <h4>Parameters</h4>
637
- <dl>
638
- <dt>description</dt><dd>A short summary of the test being defined.
639
-
640
- </dd>
641
- </dl>
642
- <h4>Examples</h4>
643
- <pre>
644
- D &quot;a new array&quot; do
645
- D .&lt; { @array = [] }
646
-
647
- D &quot;must be empty&quot; do
648
- T { @array.empty? }
649
- end
650
-
651
- D &quot;when populated&quot; do
652
- D .&lt; { @array.push 55 }
653
-
654
- D &quot;must not be empty&quot; do
655
- F { @array.empty? }
656
- end
657
- end
658
- end
659
- </pre>
660
-
661
- </div>
662
-
663
-
664
-
665
-
666
- <div class="sourcecode">
667
- <p class="source-link">
668
- Source: <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show</a>
669
-
670
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L127" target="_blank" class="github_url">on GitHub</a>
671
-
672
- </p>
673
- <div id="M000007_source" class="dyn-source">
674
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 127</span>
675
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">D</span> <span class="ruby-identifier">description</span> = <span class="ruby-identifier">caller</span>.<span class="ruby-identifier">first</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
676
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'block must be given'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">block</span>
677
- <span class="ruby-ivar">@curr_suite</span>.<span class="ruby-identifier">tests</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Suite</span><span class="ruby-operator">::</span><span class="ruby-constant">Test</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">description</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">block</span>)
678
- <span class="ruby-keyword kw">end</span></pre>
679
- </div>
680
- </div>
681
-
682
- </div>
683
-
684
- <div class="method">
685
- <div class="title" id="M000016">
686
-
687
- <a name="M000016"></a><b>E</b>(message = nil, *kinds, &amp;block)
688
-
689
- </div>
690
-
691
- <div class="description">
692
- <p>
693
- Asserts that one of the given kinds of exceptions is raised when the given
694
- block is executed.
695
- </p>
696
- <p>
697
- If the block raises an exception, then that exception is returned.
698
- </p>
699
- <p>
700
- Otherwise, nil is returned.
701
- </p>
702
- <h4>Parameters</h4>
703
- <dl>
704
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
705
-
706
- </dd>
707
- <dt>kinds</dt><dd>Exception classes that must be raised by the given block.
708
-
709
- <p>
710
- If none are given, then StandardError is assumed (similar to how a plain
711
- &#8216;rescue&#8217; statement without any arguments catches
712
- StandardError).
713
- </p>
714
- </dd>
715
- </dl>
716
- <h4>Examples</h4>
717
- <pre>
718
- # no exceptions specified:
719
-
720
- E { } # fails
721
- E { raise } # passes
722
-
723
- # single exception specified:
724
-
725
- E( ArgumentError ) { raise ArgumentError }
726
- E( &quot;argument must be invalid&quot;, ArgumentError ) { raise ArgumentError }
727
-
728
- # multiple exceptions specified:
729
-
730
- E( SyntaxError, NameError ) { eval &quot;...&quot; }
731
- E( &quot;string must compile&quot;, SyntaxError, NameError ) { eval &quot;...&quot; }
732
- </pre>
733
-
734
- </div>
735
-
736
-
737
-
738
-
739
- <div class="sourcecode">
740
- <p class="source-link">
741
- Source: <a href="javascript:toggleSource('M000016_source')" id="l_M000016_source">show</a>
742
-
743
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L352" target="_blank" class="github_url">on GitHub</a>
744
-
745
- </p>
746
- <div id="M000016_source" class="dyn-source">
747
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 352</span>
748
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">E</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
749
- <span class="ruby-identifier">assert_raise</span> <span class="ruby-identifier">:assert</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
750
- <span class="ruby-keyword kw">end</span></pre>
751
- </div>
752
- </div>
753
-
754
- </div>
755
-
756
- <div class="method">
757
- <div class="title" id="M000017">
758
-
759
- <a name="M000017"></a><b>E!</b>(message = nil, *kinds, &amp;block)
760
-
761
- </div>
762
-
763
- <div class="description">
764
- <p>
765
- Asserts that one of the given kinds of exceptions is not raised when the
766
- given block is executed.
767
- </p>
768
- <p>
769
- If the block raises an exception, then that exception is returned.
770
- </p>
771
- <p>
772
- Otherwise, nil is returned.
773
- </p>
774
- <h4>Parameters</h4>
775
- <dl>
776
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
777
-
778
- </dd>
779
- <dt>kinds</dt><dd>Exception classes that must not be raised by the given block.
780
-
781
- <p>
782
- If none are given, then StandardError is assumed (similar to how a plain
783
- &#8216;rescue&#8217; statement without any arguments catches
784
- StandardError).
785
- </p>
786
- </dd>
787
- </dl>
788
- <h4>Examples</h4>
789
- <pre>
790
- # no exceptions specified:
791
-
792
- E! { } # passes
793
- E! { raise } # fails
794
-
795
- # single exception specified:
796
-
797
- E!( ArgumentError ) { raise ArgumentError } # fails
798
- E!( &quot;argument must be invalid&quot;, ArgumentError ) { raise ArgumentError }
799
-
800
- # multiple exceptions specified:
801
-
802
- E!( SyntaxError, NameError ) { eval &quot;...&quot; }
803
- E!( &quot;string must compile&quot;, SyntaxError, NameError ) { eval &quot;...&quot; }
804
- </pre>
805
-
806
- </div>
807
-
808
-
809
-
810
-
811
- <div class="sourcecode">
812
- <p class="source-link">
813
- Source: <a href="javascript:toggleSource('M000017_source')" id="l_M000017_source">show</a>
814
-
815
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L394" target="_blank" class="github_url">on GitHub</a>
816
-
817
- </p>
818
- <div id="M000017_source" class="dyn-source">
819
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 394</span>
820
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">E!</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
821
- <span class="ruby-identifier">assert_raise</span> <span class="ruby-identifier">:negate</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
822
- <span class="ruby-keyword kw">end</span></pre>
823
- </div>
824
- </div>
825
-
826
- </div>
827
-
828
- <div class="method">
829
- <div class="title" id="M000018">
830
-
831
- <a name="M000018"></a><b>E?</b>(message = nil, *kinds, &amp;block)
832
-
833
- </div>
834
-
835
- <div class="description">
836
- <p>
837
- Returns true if one of the given kinds of exceptions is raised when the
838
- given block is executed. Otherwise, returns false.
839
- </p>
840
- <h4>Parameters</h4>
841
- <dl>
842
- <dt>message</dt><dd>This parameter is optional and completely ignored.
843
-
844
- </dd>
845
- <dt>kinds</dt><dd>Exception classes that must be raised by the given block.
846
-
847
- <p>
848
- If none are given, then StandardError is assumed (similar to how a plain
849
- &#8216;rescue&#8217; statement without any arguments catches
850
- StandardError).
851
- </p>
852
- </dd>
853
- </dl>
854
- <h4>Examples</h4>
855
- <pre>
856
- # no exceptions specified:
857
-
858
- E? { } # =&gt; false
859
- E? { raise } # =&gt; true
860
-
861
- # single exception specified:
862
-
863
- E?( ArgumentError ) { raise ArgumentError } # =&gt; true
864
-
865
- # multiple exceptions specified:
866
-
867
- E?( SyntaxError, NameError ) { eval &quot;...&quot; } # =&gt; true
868
- </pre>
869
-
870
- </div>
871
-
872
-
873
-
874
-
875
- <div class="sourcecode">
876
- <p class="source-link">
877
- Source: <a href="javascript:toggleSource('M000018_source')" id="l_M000018_source">show</a>
878
-
879
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L429" target="_blank" class="github_url">on GitHub</a>
880
-
881
- </p>
882
- <div id="M000018_source" class="dyn-source">
883
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 429</span>
884
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">E?</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
885
- <span class="ruby-identifier">assert_raise</span> <span class="ruby-identifier">:sample</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">kinds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
886
- <span class="ruby-keyword kw">end</span></pre>
887
- </div>
888
- </div>
889
-
890
- </div>
891
-
892
- <div class="method">
893
- <div class="title" id="M000015">
894
-
895
- <a name="M000015"></a><b>F?</b>(message = nil, &amp;block)
896
-
897
- </div>
898
-
899
- <div class="description">
900
- <p>
901
- Returns true if the result of the given block is either nil or false.
902
- Otherwise, returns false.
903
- </p>
904
- <h4>Parameters</h4>
905
- <dl>
906
- <dt>message</dt><dd>This parameter is optional and completely ignored.
907
-
908
- </dd>
909
- </dl>
910
- <h4>Examples</h4>
911
- <pre>
912
- # no message specified:
913
-
914
- F? { true } # =&gt; false
915
- F? { false } # =&gt; true
916
- F? { nil } # =&gt; true
917
-
918
- # message specified:
919
-
920
- F?( &quot;computers do not doublethink&quot; ) { 2 + 2 == 5 } # =&gt; true
921
- </pre>
922
-
923
- </div>
924
-
925
-
926
-
927
-
928
- <div class="sourcecode">
929
- <p class="source-link">
930
- Source: <a href="javascript:toggleSource('M000015_source')" id="l_M000015_source">show</a>
931
-
932
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L309" target="_blank" class="github_url">on GitHub</a>
933
-
934
- </p>
935
- <div id="M000015_source" class="dyn-source">
936
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 309</span>
937
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">F?</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
938
- <span class="ruby-keyword kw">not</span> <span class="ruby-constant">T?</span> <span class="ruby-identifier">message</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
939
- <span class="ruby-keyword kw">end</span></pre>
940
- </div>
941
- </div>
942
-
943
- </div>
944
-
945
- <div class="method">
946
- <div class="title" id="M000022">
947
-
948
- <a name="M000022"></a><b>S</b>(*message)
949
-
950
- </div>
951
-
952
- <div class="description">
953
- <p>
954
- Adds the given message to the report inside the section of the currently
955
- running test.
956
- </p>
957
- <p>
958
- You can think of &#8220;S&#8221; as &#8220;say&#8221; or
959
- &#8220;status&#8221;.
960
- </p>
961
- <h4>Parameters</h4>
962
- <dl>
963
- <dt>message</dt><dd>Objects to be added to the report.
964
-
965
- </dd>
966
- </dl>
967
- <h4>Examples</h4>
968
- <pre>
969
- S &quot;establishing connection...&quot;
970
-
971
- S &quot;beginning calculation...&quot;, Math::PI, [1, 2, 3, ['a', 'b', 'c']]
972
- </pre>
973
-
974
- </div>
975
-
976
-
977
-
978
-
979
- <div class="sourcecode">
980
- <p class="source-link">
981
- Source: <a href="javascript:toggleSource('M000022_source')" id="l_M000022_source">show</a>
982
-
983
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L544" target="_blank" class="github_url">on GitHub</a>
984
-
985
- </p>
986
- <div id="M000022_source" class="dyn-source">
987
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 544</span>
988
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">S</span> <span class="ruby-operator">*</span><span class="ruby-identifier">message</span>
989
- <span class="ruby-ivar">@exec_trace</span>.<span class="ruby-identifier">concat</span> <span class="ruby-identifier">message</span>
990
- <span class="ruby-keyword kw">end</span></pre>
991
- </div>
992
- </div>
993
-
994
- </div>
995
-
996
- <div class="method">
997
- <div class="title" id="M000012">
998
-
999
- <a name="M000012"></a><b>T</b>(message = nil, &amp;block)
1000
-
1001
- </div>
1002
-
1003
- <div class="description">
1004
- <p>
1005
- Asserts that the result of the given block is neither nil nor false and
1006
- returns that result.
1007
- </p>
1008
- <h4>Parameters</h4>
1009
- <dl>
1010
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
1011
-
1012
- </dd>
1013
- </dl>
1014
- <h4>Examples</h4>
1015
- <pre>
1016
- # no message specified:
1017
-
1018
- T { true } # passes
1019
- T { false } # fails
1020
- T { nil } # fails
1021
-
1022
- # message specified:
1023
-
1024
- T( &quot;computers do not doublethink&quot; ) { 2 + 2 != 5 } # passes
1025
- </pre>
1026
-
1027
- </div>
1028
-
1029
-
1030
-
1031
-
1032
- <div class="sourcecode">
1033
- <p class="source-link">
1034
- Source: <a href="javascript:toggleSource('M000012_source')" id="l_M000012_source">show</a>
1035
-
1036
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L229" target="_blank" class="github_url">on GitHub</a>
1037
-
1038
- </p>
1039
- <div id="M000012_source" class="dyn-source">
1040
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 229</span>
1041
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">T</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1042
- <span class="ruby-identifier">assert_yield</span> <span class="ruby-identifier">:assert</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1043
- <span class="ruby-keyword kw">end</span></pre>
1044
- </div>
1045
- </div>
1046
-
1047
- </div>
1048
-
1049
- <div class="method">
1050
- <div class="title" id="M000013">
1051
-
1052
- <a name="M000013"></a><b>T!</b>(message = nil, &amp;block)
1053
-
1054
- </div>
1055
-
1056
- <div class="description">
1057
- <p>
1058
- Asserts that the result of the given block is either nil or false and
1059
- returns that result.
1060
- </p>
1061
- <h4>Parameters</h4>
1062
- <dl>
1063
- <dt>message</dt><dd>Optional message to show in the report if this assertion fails.
1064
-
1065
- </dd>
1066
- </dl>
1067
- <h4>Examples</h4>
1068
- <pre>
1069
- # no message specified:
1070
-
1071
- T! { true } # fails
1072
- T! { false } # passes
1073
- T! { nil } # passes
1074
-
1075
- # message specified:
1076
-
1077
- T!( &quot;computers do not doublethink&quot; ) { 2 + 2 == 5 } # passes
1078
- </pre>
1079
-
1080
- </div>
1081
-
1082
-
1083
-
1084
-
1085
- <div class="sourcecode">
1086
- <p class="source-link">
1087
- Source: <a href="javascript:toggleSource('M000013_source')" id="l_M000013_source">show</a>
1088
-
1089
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L255" target="_blank" class="github_url">on GitHub</a>
1090
-
1091
- </p>
1092
- <div id="M000013_source" class="dyn-source">
1093
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 255</span>
1094
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">T!</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1095
- <span class="ruby-identifier">assert_yield</span> <span class="ruby-identifier">:negate</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1096
- <span class="ruby-keyword kw">end</span></pre>
1097
- </div>
1098
- </div>
1099
-
1100
- </div>
1101
-
1102
- <div class="method">
1103
- <div class="title" id="M000014">
1104
-
1105
- <a name="M000014"></a><b>T?</b>(message = nil, &amp;block)
1106
-
1107
- </div>
1108
-
1109
- <div class="description">
1110
- <p>
1111
- Returns true if the result of the given block is neither nil nor false.
1112
- Otherwise, returns false.
1113
- </p>
1114
- <h4>Parameters</h4>
1115
- <dl>
1116
- <dt>message</dt><dd>This parameter is optional and completely ignored.
1117
-
1118
- </dd>
1119
- </dl>
1120
- <h4>Examples</h4>
1121
- <pre>
1122
- # no message specified:
1123
-
1124
- T? { true } # =&gt; true
1125
- T? { false } # =&gt; false
1126
- T? { nil } # =&gt; false
1127
-
1128
- # message specified:
1129
-
1130
- T?( &quot;computers do not doublethink&quot; ) { 2 + 2 != 5 } # =&gt; true
1131
- </pre>
1132
-
1133
- </div>
1134
-
1135
-
1136
-
1137
-
1138
- <div class="sourcecode">
1139
- <p class="source-link">
1140
- Source: <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show</a>
1141
-
1142
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L280" target="_blank" class="github_url">on GitHub</a>
1143
-
1144
- </p>
1145
- <div id="M000014_source" class="dyn-source">
1146
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 280</span>
1147
- <span class="ruby-keyword kw">def</span> <span class="ruby-constant">T?</span> <span class="ruby-identifier">message</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1148
- <span class="ruby-identifier">assert_yield</span> <span class="ruby-identifier">:sample</span>, <span class="ruby-identifier">message</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
1149
- <span class="ruby-keyword kw">end</span></pre>
1150
- </div>
1151
- </div>
1152
-
1153
- </div>
1154
-
1155
- <div class="method">
1156
- <div class="title" id="M000023">
1157
-
1158
- <a name="M000023"></a><b>run</b>(continue = true)
1159
-
1160
- </div>
1161
-
1162
- <div class="description">
1163
- <p>
1164
- Executes all tests defined thus far and stores the results in <a
1165
- href="Dfect.html#report">report</a>.
1166
- </p>
1167
- <h4>Parameters</h4>
1168
- <dl>
1169
- <dt>continue</dt><dd>If true, results from previous executions will not be cleared.
1170
-
1171
- </dd>
1172
- </dl>
1173
-
1174
- </div>
1175
-
1176
-
1177
-
1178
-
1179
- <div class="sourcecode">
1180
- <p class="source-link">
1181
- Source: <a href="javascript:toggleSource('M000023_source')" id="l_M000023_source">show</a>
1182
-
1183
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L556" target="_blank" class="github_url">on GitHub</a>
1184
-
1185
- </p>
1186
- <div id="M000023_source" class="dyn-source">
1187
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 556</span>
1188
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span> <span class="ruby-identifier">continue</span> = <span class="ruby-keyword kw">true</span>
1189
- <span class="ruby-comment cmt"># clear previous results</span>
1190
- <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">continue</span>
1191
- <span class="ruby-ivar">@exec_stats</span>.<span class="ruby-identifier">clear</span>
1192
- <span class="ruby-ivar">@exec_trace</span>.<span class="ruby-identifier">clear</span>
1193
- <span class="ruby-ivar">@test_stack</span>.<span class="ruby-identifier">clear</span>
1194
- <span class="ruby-keyword kw">end</span>
1195
-
1196
- <span class="ruby-comment cmt"># make new results</span>
1197
- <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:stop_dfect_execution</span>) { <span class="ruby-identifier">execute</span> }
1198
-
1199
- <span class="ruby-comment cmt"># print new results</span>
1200
- <span class="ruby-identifier">puts</span> <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">to_yaml</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:quiet</span>]
1201
- <span class="ruby-keyword kw">end</span></pre>
1202
- </div>
1203
- </div>
1204
-
1205
- </div>
1206
-
1207
- <div class="method">
1208
- <div class="title" id="M000024">
1209
-
1210
- <a name="M000024"></a><b>stop</b>()
1211
-
1212
- </div>
1213
-
1214
- <div class="description">
1215
- <p>
1216
- Stops the execution of the <a href="Dfect.html#M000023">run</a> method or
1217
- raises an exception if that method is not currently executing.
1218
- </p>
1219
-
1220
- </div>
1221
-
1222
-
1223
-
1224
-
1225
- <div class="sourcecode">
1226
- <p class="source-link">
1227
- Source: <a href="javascript:toggleSource('M000024_source')" id="l_M000024_source">show</a>
1228
-
1229
- | <a href="http://github.com/sunaku/dfect/blob/147e36e24957caf3763b5e28f7040f623e275625/lib/dfect.rb#L575" target="_blank" class="github_url">on GitHub</a>
1230
-
1231
- </p>
1232
- <div id="M000024_source" class="dyn-source">
1233
- <pre><span class="ruby-comment cmt"># File lib/dfect.rb, line 575</span>
1234
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
1235
- <span class="ruby-identifier">throw</span> <span class="ruby-identifier">:stop_dfect_execution</span>
1236
- <span class="ruby-keyword kw">end</span></pre>
1237
- </div>
1238
- </div>
1239
-
1240
- </div>
1241
-
1242
- </div>
1243
- </div>
1244
- </body>
1245
- </html>