dfect 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +2 -2
- data/HISTORY +306 -0
- data/INSTALL +35 -0
- data/README +95 -0
- data/USAGE +393 -0
- data/doc/api/Dfect.html +3179 -0
- data/doc/api/Object.html +107 -0
- data/doc/api/_index.html +107 -0
- data/doc/api/class_list.html +36 -0
- data/doc/api/css/common.css +1 -0
- data/doc/api/css/full_list.css +50 -0
- data/doc/api/css/style.css +268 -0
- data/doc/api/file.LICENSE.html +73 -0
- data/doc/api/file_list.html +38 -0
- data/doc/api/frames.html +13 -0
- data/doc/api/index.html +72 -13
- data/doc/api/js/app.js +99 -0
- data/doc/api/js/full_list.js +106 -0
- data/doc/api/js/{jquery-1.3.2.min.js → jquery.js} +0 -0
- data/doc/api/method_list.html +339 -0
- data/doc/api/top-level-namespace.html +87 -0
- data/doc/index.erb +16 -9
- data/doc/index.html +1057 -726
- data/lib/dfect.rb +431 -284
- data/lib/dfect/auto.rb +2 -6
- data/lib/dfect/inochi.rb +48 -0
- data/lib/dfect/inochi.yaml +75 -0
- data/lib/dfect/mini.rb +1 -5
- data/lib/dfect/spec.rb +6 -13
- data/lib/dfect/unit.rb +21 -33
- data/test/dfect/inochi_test.rb +17 -0
- data/test/{dfect.rb → dfect_test.rb} +167 -7
- data/test/runner +25 -0
- data/test/test_helper.rb +1 -0
- metadata +43 -55
- data/doc/api/apple-touch-icon.png +0 -0
- data/doc/api/classes/Class.html +0 -73
- data/doc/api/classes/Dfect.html +0 -1245
- data/doc/api/classes/Kernel.html +0 -322
- data/doc/api/classes/Object.html +0 -72
- data/doc/api/created.rid +0 -1
- data/doc/api/css/main.css +0 -263
- data/doc/api/css/panel.css +0 -383
- data/doc/api/css/reset.css +0 -53
- data/doc/api/favicon.ico +0 -0
- data/doc/api/files/CREDITS.html +0 -65
- data/doc/api/files/LICENSE.html +0 -76
- data/doc/api/files/lib/dfect/auto_rb.html +0 -80
- data/doc/api/files/lib/dfect/mini_rb.html +0 -77
- data/doc/api/files/lib/dfect/spec_rb.html +0 -73
- data/doc/api/files/lib/dfect/unit_rb.html +0 -73
- data/doc/api/files/lib/dfect_rb.html +0 -74
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/js/jquery-effect.js +0 -593
- data/doc/api/js/main.js +0 -22
- data/doc/api/js/searchdoc.js +0 -628
- data/doc/api/panel/index.html +0 -71
- data/doc/api/panel/search_index.js +0 -1
- data/doc/api/panel/tree.js +0 -1
- data/doc/history.erb +0 -161
- data/doc/intro.erb +0 -104
- data/doc/setup.erb +0 -107
- data/doc/usage.erb +0 -310
- data/rakefile +0 -21
data/doc/usage.erb
DELETED
@@ -1,310 +0,0 @@
|
|
1
|
-
%#--
|
2
|
-
%# Copyright protects this work.
|
3
|
-
%# See LICENSE file for details.
|
4
|
-
%#++
|
5
|
-
|
6
|
-
% dfect_api = 'api/classes/Dfect.html'
|
7
|
-
|
8
|
-
|
9
|
-
%|chapter "Usage"
|
10
|
-
|
11
|
-
Begin by loading <%= $project %> into your program:
|
12
|
-
|
13
|
-
%|code :ruby
|
14
|
-
require 'rubygems' # only necessary if you are using Ruby 1.8
|
15
|
-
require 'dfect'
|
16
|
-
|
17
|
-
You now have access to the [`Dfect` module](<%= dfect_api %>), which provides methods that can be mixed-in or called directly, according to your preference:
|
18
|
-
|
19
|
-
%|code :ruby
|
20
|
-
Dfect.D "hello" do # D() is a class method
|
21
|
-
puts "world"
|
22
|
-
end
|
23
|
-
|
24
|
-
# the above is same as:
|
25
|
-
|
26
|
-
include Dfect # mix-in the Dfect API
|
27
|
-
|
28
|
-
D "hello" do # D() is an instance method
|
29
|
-
puts "world"
|
30
|
-
end
|
31
|
-
|
32
|
-
The following sections explain these provided methods in detail. If you are impatient, you can skip to <%= xref "A sample unit test" %> for an illustrative example.
|
33
|
-
|
34
|
-
|
35
|
-
%|section "Assertions"
|
36
|
-
|
37
|
-
The following methods accept a block parameter and assert something about the result of executing that block. They also accept an optional message, which is shown in <%= xref "Failures", "failure reports" %> if they fail.
|
38
|
-
|
39
|
-
See the [API documentation](<%= api_url %>) for details and examples.
|
40
|
-
|
41
|
-
%|table
|
42
|
-
%|thead
|
43
|
-
%|tr
|
44
|
-
%|th
|
45
|
-
Method
|
46
|
-
%|th
|
47
|
-
Description
|
48
|
-
%|tbody
|
49
|
-
%|tr
|
50
|
-
%|td
|
51
|
-
T
|
52
|
-
%|td
|
53
|
-
assert true (not `nil` and not `false`)
|
54
|
-
%|tr
|
55
|
-
%|td
|
56
|
-
F
|
57
|
-
%|td
|
58
|
-
assert not true (`nil` or `false`)
|
59
|
-
%|tr
|
60
|
-
%|td
|
61
|
-
E
|
62
|
-
%|td
|
63
|
-
assert that an execption is raised
|
64
|
-
%|tr
|
65
|
-
%|td
|
66
|
-
C
|
67
|
-
%|td
|
68
|
-
assert that a symbol is thrown
|
69
|
-
|
70
|
-
|
71
|
-
%|paragraph "Negation"
|
72
|
-
|
73
|
-
These methods are the *opposite* of <%= xref "Assertions", "normal assertions" %>.
|
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
|
-
same as F
|
88
|
-
%|tr
|
89
|
-
%|td
|
90
|
-
F!
|
91
|
-
%|td
|
92
|
-
same as T
|
93
|
-
%|tr
|
94
|
-
%|td
|
95
|
-
E!
|
96
|
-
%|td
|
97
|
-
assert that an exception is *not* raised
|
98
|
-
%|tr
|
99
|
-
%|td
|
100
|
-
C!
|
101
|
-
%|td
|
102
|
-
assert that a symbol is *not* thrown
|
103
|
-
|
104
|
-
|
105
|
-
%|paragraph "Sampling"
|
106
|
-
|
107
|
-
These methods allow you to *check the outcome* of an <%= xref "Assertions", "assertion" %> without including the assertion in the execution report.
|
108
|
-
|
109
|
-
%|table
|
110
|
-
%|thead
|
111
|
-
%|tr
|
112
|
-
%|th
|
113
|
-
Method
|
114
|
-
%|th
|
115
|
-
Description
|
116
|
-
%|tbody
|
117
|
-
%|tr
|
118
|
-
%|td
|
119
|
-
T?
|
120
|
-
%|td
|
121
|
-
returns `true` if T passes; `false` otherwise
|
122
|
-
%|tr
|
123
|
-
%|td
|
124
|
-
F?
|
125
|
-
%|td
|
126
|
-
returns `true` if F passes; `false` otherwise
|
127
|
-
%|tr
|
128
|
-
%|td
|
129
|
-
E?
|
130
|
-
%|td
|
131
|
-
returns `true` if E passes; `false` otherwise
|
132
|
-
%|tr
|
133
|
-
%|td
|
134
|
-
C?
|
135
|
-
%|td
|
136
|
-
returns `true` if C passes; `false` otherwise
|
137
|
-
|
138
|
-
|
139
|
-
%|section "Failures"
|
140
|
-
|
141
|
-
When an assertion fails, details about the failure will be shown:
|
142
|
-
|
143
|
-
- fail: block must yield true (!nil && !false)
|
144
|
-
code: |-
|
145
|
-
[12..22] in test/simple.rb
|
146
|
-
12
|
147
|
-
13 D "with more nested tests" do
|
148
|
-
14 x = 5
|
149
|
-
15
|
150
|
-
16 T { x > 2 } # passes
|
151
|
-
=> 17 F { x > 2 } # fails
|
152
|
-
18 E { x.hello } # passes
|
153
|
-
19 end
|
154
|
-
20 end
|
155
|
-
21
|
156
|
-
22 # equivalent of before(:each) or setup()
|
157
|
-
vars:
|
158
|
-
x: 5
|
159
|
-
y: 83
|
160
|
-
call:
|
161
|
-
- test/simple.rb:17
|
162
|
-
- test/simple.rb:3
|
163
|
-
|
164
|
-
You will then be placed into a debugger to investigate the failure if the `:debug` option is enabled in [`Dfect.options`](<%= dfect_api %>).
|
165
|
-
|
166
|
-
Details about all assertion failures and a trace of all tests executed are stored by <%= $project %> and provided by the [`Dfect.report`](<%= dfect_api %>) method.
|
167
|
-
|
168
|
-
|
169
|
-
%|section "Tests"
|
170
|
-
|
171
|
-
The [`D()` method](<%= dfect_api %>) defines a new **test**, which is analagous to the `describe()` environment provided by BDD frameworks like RSpec.
|
172
|
-
|
173
|
-
A test may also contain nested tests.
|
174
|
-
|
175
|
-
%|code :ruby
|
176
|
-
D "outer test" do
|
177
|
-
# assertions and logic here
|
178
|
-
|
179
|
-
D "inner test" do
|
180
|
-
# more assertions and logic here
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
|
185
|
-
%|section "Hooks"
|
186
|
-
|
187
|
-
The [`D()` method](<%= dfect_api %>) provides several entry points (hooks) into the test execution process:
|
188
|
-
|
189
|
-
%|code :ruby
|
190
|
-
D "outer test" do
|
191
|
-
D .< { puts "before each nested test" }
|
192
|
-
D .> { puts "after each nested test" }
|
193
|
-
D .<< { puts "before all nested tests" }
|
194
|
-
D .>> { puts "after all nested tests" }
|
195
|
-
|
196
|
-
D "inner test" do
|
197
|
-
# assertions and logic here
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
A hook method may be called multiple times. Each call registers additional logic to execute during the hook:
|
202
|
-
|
203
|
-
%|code :ruby
|
204
|
-
D .< { puts "do something" }
|
205
|
-
D .< { puts "do something more!" }
|
206
|
-
|
207
|
-
|
208
|
-
%|section "Insulation"
|
209
|
-
|
210
|
-
Use the singleton class of a temporary object to shield your test logic from Ruby's global environment, the code being tested, and from other tests:
|
211
|
-
|
212
|
-
%|code :ruby
|
213
|
-
class << Object.new
|
214
|
-
# your test logic here
|
215
|
-
end
|
216
|
-
|
217
|
-
Inside this insulated environment, you are free to:
|
218
|
-
* mix-in any modules your test logic needs
|
219
|
-
* define your own constants, methods, and classes
|
220
|
-
|
221
|
-
For example:
|
222
|
-
|
223
|
-
%|code :ruby
|
224
|
-
class << Object.new
|
225
|
-
include SomeModule
|
226
|
-
extend AnotherModule
|
227
|
-
|
228
|
-
YOUR_CONSTANT = 123
|
229
|
-
|
230
|
-
D "your tests here" do
|
231
|
-
# your test logic here
|
232
|
-
|
233
|
-
your_helper_method
|
234
|
-
end
|
235
|
-
|
236
|
-
def self.your_helper_method
|
237
|
-
# your helper logic here
|
238
|
-
|
239
|
-
helper = YourHelperClass.new
|
240
|
-
helper.do_something_helpful
|
241
|
-
|
242
|
-
T { 2 + 2 != 5 }
|
243
|
-
end
|
244
|
-
|
245
|
-
class YourHelperClass
|
246
|
-
# your helper logic here
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
|
251
|
-
%|section "Execution"
|
252
|
-
|
253
|
-
You can configure test execution using:
|
254
|
-
|
255
|
-
%|code :ruby
|
256
|
-
Dfect.options = your_options_hash
|
257
|
-
|
258
|
-
You can execute all tests defined thus far using:
|
259
|
-
|
260
|
-
%|code :ruby
|
261
|
-
Dfect.run
|
262
|
-
|
263
|
-
You can stop this execution at any time using:
|
264
|
-
|
265
|
-
%|code :ruby
|
266
|
-
Dfect.stop
|
267
|
-
|
268
|
-
You can view the results of execution using:
|
269
|
-
|
270
|
-
%|code :ruby
|
271
|
-
puts Dfect.report.to_yaml
|
272
|
-
|
273
|
-
See the [API documentation](<%= api_url %>) for details and examples.
|
274
|
-
|
275
|
-
|
276
|
-
%|section "Automatic test execution"
|
277
|
-
|
278
|
-
%|code :ruby
|
279
|
-
require 'rubygems' # only necessary if you are using Ruby 1.8
|
280
|
-
require 'dfect/auto' # <== notice the "auto"
|
281
|
-
|
282
|
-
The above code will mix-in the `Dfect` module into your program and will execute all tests defined by your program before it terminates.
|
283
|
-
|
284
|
-
|
285
|
-
%|section "Reporting"
|
286
|
-
|
287
|
-
You can insert status messages, which can be arbitrary Ruby objects, into the execution report using the `Dfect::S()` method.
|
288
|
-
|
289
|
-
See the [API documentation](<%= api_url %>) for details and examples.
|
290
|
-
|
291
|
-
|
292
|
-
%|section "Emulation"
|
293
|
-
|
294
|
-
Dfect provides emulation layers for several popular testing libraries:
|
295
|
-
|
296
|
-
* <tt>dfect/unit</tt> --- Test::Unit
|
297
|
-
* <tt>dfect/mini</tt> --- Minitest
|
298
|
-
* <tt>dfect/spec</tt> --- RSpec
|
299
|
-
|
300
|
-
Simply `require()` one of these emulation layers into your test suite and you can write your tests using the familiar syntax of that testing library.
|
301
|
-
|
302
|
-
See the [API documentation](<%= api_url %>) for details and examples.
|
303
|
-
|
304
|
-
|
305
|
-
%|example! "A sample unit test"
|
306
|
-
|
307
|
-
The following code is from Dfect's very own test suite.
|
308
|
-
|
309
|
-
%|code :ruby
|
310
|
-
%< "../test/dfect.rb"
|
data/rakefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright protects this work.
|
3
|
-
# See LICENSE file for details.
|
4
|
-
#++
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
gem 'inochi', '~> 1'
|
8
|
-
require 'inochi'
|
9
|
-
|
10
|
-
Inochi.init :Dfect,
|
11
|
-
:version => '1.1.0',
|
12
|
-
:release => '2009-10-27',
|
13
|
-
:website => 'http://snk.tuxfamily.org/lib/dfect/',
|
14
|
-
:tagline => 'Assertion testing library for Ruby'
|
15
|
-
|
16
|
-
Inochi.rake :Dfect,
|
17
|
-
:test_with => :dfect,
|
18
|
-
:rubyforge_project => 'sunaku',
|
19
|
-
:upload_target => File.expand_path('~/www/lib/dfect/'),
|
20
|
-
:upload_delete => true,
|
21
|
-
:inochi_consumer => false
|