dfect 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/doc/intro.erb CHANGED
@@ -1,21 +1,32 @@
1
+ % api_url = './api/index.html'
2
+ % src_url = 'http://github.com/sunaku/' + $program
3
+ % git_url = 'http://git-scm.com'
4
+
1
5
  %|chapter "Introduction"
2
- %|project_summary
3
- **<%= $project %>** is an assertion testing library for Ruby that emphasizes a simple assertion vocabulary, instant debuggability of failures, and flexibility in composing tests.
6
+ %|project
7
+ <%= $project %> is an assertion testing library for Ruby that emphasizes a simple assertion vocabulary, instant debuggability of failures, and flexibility in composing tests.
4
8
 
5
- **<%= $project %>** is exciting because:
6
- * It has only 5 methods to remember: D F E C T.
7
- * It lets you debug assertion failures interactively.
8
- * It keeps a detailed report of assertion failures.
9
- * It lets you nest tests and execution hooks.
10
- * It is implemented in a mere <%= `sloccount lib`[/^\d+/] %> lines of code.
9
+ <%= $project %> is exciting because:
10
+ * It has only 5 methods to remember: D F E C T.
11
+ * It lets you debug assertion failures interactively.
12
+ * It keeps a detailed report of assertion failures.
13
+ * It lets you nest tests and execution hooks.
14
+ * It is implemented in a mere <%= `sloccount lib`[/^\d+/] %> lines of code.
11
15
 
12
- These features distinguish **<%= $project %>** from the competition:
16
+ These features distinguish <%= $project %> from the competition:
13
17
  * [assert{ 2.0 }](http://assert2.rubyforge.org)
14
18
  * [Verify](http://www.ruby-forum.com/topic/183354)
15
19
  * [Testy](http://www.ruby-forum.com/topic/182798)
20
+ * [minitest](http://blog.zenspider.com/minitest)
21
+ * [Context](http://github.com/jeremymcanally/context)
22
+ * [Shoulda](http://thoughtbot.com/projects/shoulda)
23
+ * [Bacon](http://chneukirchen.org/repos/bacon/README)
24
+ * [test-spec](http://test-spec.rubyforge.org/test-spec)
25
+ * [RSpec](http://rspec.info)
26
+ * [Test::Unit](http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/index.html)
16
27
 
17
28
  %|paragraph "Etymology"
18
- **<%= $project %>** is named after the 5 methods it provides: D F E C T.
29
+ <%= $project %> is named after the D F E C T methods it provides.
19
30
 
20
31
  The name is also play on the word "defect", whereby the intentional misspelling of "defect" as "dfect" is a defect in itself! <tt>;-)</tt>
21
32
 
@@ -23,14 +34,14 @@
23
34
 
24
35
  %|section "Logistics"
25
36
  * <%= xref "History", "Release notes" %> --- history of project releases.
26
- * [Source code](http://github.com/sunaku/<%= $program %>) --- obtain via [Git](http://git.or.cz) or browse online.
27
- * [API reference](api/index.html) --- documentation for source code.
37
+ * [Source code](<%= src_url %>) --- obtain via [Git](<%= git_url %>) or browse online.
38
+ * [API reference](<%= api_url %>) --- documentation for source code.
28
39
 
29
40
  To get help or provide feedback, simply
30
41
  <%= xref "License", "contact the author(s)" %>.
31
42
 
32
43
  %|paragraph "Version numbers"
33
- **<%= $project %>** releases are numbered in *major.minor.patch*
44
+ <%= $project %> releases are numbered in *major.minor.patch*
34
45
  form according to the [RubyGems rational versioning
35
46
  policy](http://www.rubygems.org/read/chapter/7), which
36
47
  can be summarized thus:
@@ -73,6 +84,8 @@
73
84
  %< "../LICENSE"
74
85
 
75
86
  %|section "Credits"
76
- **<%= $project %>** is made possible by
87
+ <%= $project %> is made possible by
77
88
  <%= xref "History", "contributions" %>
78
- from users like you.
89
+ from users like you:
90
+
91
+ %< "../CREDITS"
data/doc/setup.erb CHANGED
@@ -1,6 +1,6 @@
1
1
  %|chapter "Setup"
2
2
  %|section "Requirements"
3
- Your system needs the following software to run **<%= $project %>**.
3
+ Your system needs the following software to run <%= $project %>.
4
4
 
5
5
  | Software | Description | Notes |
6
6
  | -------- | ----------- | ----- |
@@ -9,17 +9,17 @@
9
9
  | [ruby-debug](http://www.datanoise.com/ruby-debug) | Interactive debugger | This is an _optional_ requirement; IRB will be used if this library is not available. |
10
10
 
11
11
  %|section "Installation"
12
- You can install **<%= $project %>** by running this command:
12
+ You can install <%= $project %> by running this command:
13
13
 
14
14
  gem install <%= $program %>
15
15
 
16
16
  %|section "Manifest"
17
- You will see the following items inside **<%= $project %>**'s installation
17
+ You will see the following items inside <%= $project %>'s installation
18
18
  directory:
19
19
 
20
20
  * <tt>lib/</tt>
21
21
 
22
- * <tt><%= $program %>.rb</tt> --- the main **<%= $project %>** library.
22
+ * <tt><%= $program %>.rb</tt> --- the main <%= $project %> library.
23
23
 
24
24
  * <tt><%= $program %>/</tt>
25
25
 
data/doc/usage.erb CHANGED
@@ -1,17 +1,17 @@
1
1
  % dfect_api = 'api/classes/Dfect.html'
2
2
 
3
3
  %|chapter "Usage"
4
- Begin by loading **<%= $project %>** into your program:
4
+ Begin by loading <%= $project %> into your program:
5
5
 
6
6
  <code>
7
7
  require 'rubygems'
8
8
  require 'dfect'
9
9
  </code>
10
10
 
11
- Now you have access to the [`Dfect` module](<%= dfect_api %>), which provides mixin-able instance methods which are also directly-callable as module functions (class methods):
11
+ You now have access to the [`Dfect` module](<%= dfect_api %>), which provides mixin-able instance methods that are also directly-callable as class methods:
12
12
 
13
13
  <code>
14
- Dfect.D "hello" do
14
+ Dfect.D "hello" do # D() is a not-mixed-in class method
15
15
  puts "world"
16
16
  end
17
17
 
@@ -19,52 +19,72 @@
19
19
 
20
20
  include Dfect
21
21
 
22
- D "hello" do
22
+ D "hello" do # D() is a mixed-in instance method
23
23
  puts "world"
24
24
  end
25
25
  </code>
26
26
 
27
- The following sections explain these methods in detail.
27
+ The following sections explain these provided methods in detail.
28
28
 
29
29
  %|section "Assertions"
30
- The following methods take a block parameter and assert something about the result of executing that block. Follow the links into the API documentation for examples.
31
-
32
- * [`T()`](<%= dfect_api %>) --- assert true (not nil and not false)
33
- * [`F()`](<%= dfect_api %>) --- assert not true (nil or false)
34
- * [`E()`](<%= dfect_api %>) --- assert that an execption is raised
35
- * [`C()`](<%= dfect_api %>) --- assert that a symbol is caught
30
+ The following methods take a block parameter and assert something about the result of executing that block. See the [API documentation](<%= dfect_api %>) for examples.
31
+
32
+ | Method | Description |
33
+ | ------ | ----------- |
34
+ | F | assert not true (`nil` or `false`) |
35
+ | E | assert that an execption is raised |
36
+ | C | assert that a symbol is thrown |
37
+ | T | assert true (not `nil` and not `false`) |
38
+
39
+ %|paragraph "Negation"
40
+ These methods are the *opposite* of <%= xref "Assertions", "normal assertions" %>.
41
+
42
+ | Method | Description |
43
+ | ------ | ----------- |
44
+ | F! | same as T |
45
+ | E! | assert that an execption is *not* raised |
46
+ | C! | assert that a symbol is *not* thrown |
47
+ | T! | same as F |
48
+
49
+ %|paragraph "Sampling"
50
+ These methods allow you to *check the outcome* of an <%= xref "Assertions", "assertion" %> without the penalty of pass or failure.
51
+
52
+ | Method | Description |
53
+ | ------ | ----------- |
54
+ | F? | returns `true` if F passes; `false` otherwise |
55
+ | E? | returns `true` if E passes; `false` otherwise |
56
+ | C? | returns `true` if C passes; `false` otherwise |
57
+ | T? | returns `true` if T passes; `false` otherwise |
36
58
 
37
59
  %|section "Failures"
38
- When an assertion fails, the details about the failure will be shown like this:
60
+ When an assertion fails, details about the failure will be shown:
39
61
 
40
62
  <pre>
41
- - a complex test:
42
- - with more nested tests:
43
- - fail: block must yield true (!nil && !false)
44
- code: |-
45
- [12..22] in test/simple.rb
46
- 12
47
- 13 D "with more nested tests" do
48
- 14 x = 5
49
- 15
50
- 16 T { x > 2 } # passes
51
- => 17 F { x > 2 } # fails
52
- 18 E { x.hello } # fails
53
- 19 end
54
- 20 end
55
- 21
56
- 22 # equivalent of before(:each) or setup()
57
- vars:
58
- x: 5
59
- y: 83
60
- call:
61
- - test/simple.rb:17
62
- - test/simple.rb:3
63
+ - fail: block must yield true (!nil && !false)
64
+ code: |-
65
+ [12..22] in test/simple.rb
66
+ 12
67
+ 13 D "with more nested tests" do
68
+ 14 x = 5
69
+ 15
70
+ 16 T { x > 2 } # passes
71
+ => 17 F { x > 2 } # fails
72
+ 18 E { x.hello } # passes
73
+ 19 end
74
+ 20 end
75
+ 21
76
+ 22 # equivalent of before(:each) or setup()
77
+ vars:
78
+ x: 5
79
+ y: 83
80
+ call:
81
+ - test/simple.rb:17
82
+ - test/simple.rb:3
63
83
  </pre>
64
84
 
65
- If the `:debug` option is enabled in [`Dfect.options`](<%= dfect_api %>), you will then be placed into a debugger to investigate the failure.
85
+ You will then be placed into a debugger to investigate the failure if the `:debug` option is enabled in [`Dfect.options`](<%= dfect_api %>).
66
86
 
67
- 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.
87
+ 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.
68
88
 
69
89
  %|section "Tests"
70
90
  The [`D()` method](<%= dfect_api %>) defines a new **test**, which is analagous to the `describe()` environment provided by BDD frameworks like RSpec.
@@ -104,11 +124,54 @@
104
124
  D .< { puts "do something more!" }
105
125
  </code>
106
126
 
127
+ %|section "Insulation"
128
+ 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:
129
+
130
+ <code>
131
+ class << Object.new
132
+ # your test logic here
133
+ end
134
+ </code>
135
+
136
+ Inside this insulated environment, you are free to:
137
+ * mix-in any modules your test logic needs
138
+ * define your own constants, methods, and classes
139
+
140
+ For example:
141
+
142
+ <code>
143
+ class << Object.new
144
+ include SomeModule
145
+ extend AnotherModule
146
+
147
+ YOUR_CONSTANT = 123
148
+
149
+ D "your tests here" do
150
+ # your test logic here
151
+
152
+ your_helper_method
153
+ end
154
+
155
+ def self.your_helper_method
156
+ # your helper logic here
157
+
158
+ helper = YourHelperClass.new
159
+ helper.do_something_helpful
160
+
161
+ T { 2 + 2 != 5 }
162
+ end
163
+
164
+ class YourHelperClass
165
+ # your helper logic here
166
+ end
167
+ end
168
+ </code>
169
+
107
170
  %|section "Execution"
108
171
  You can configure test execution using:
109
172
 
110
173
  <code>
111
- Dfect.options = your_options
174
+ Dfect.options = your_options_hash
112
175
  </code>
113
176
 
114
177
  You can execute all tests defined thus far using:
@@ -159,27 +222,23 @@
159
222
 
160
223
  T { x > 2 } # passes
161
224
  F { x > 2 } # fails
162
- E { x.hello } # fails
225
+ E { x.hello } # passes
163
226
  end
164
227
  end
165
228
 
166
- # equivalent of before(:each) or setup()
167
- D.< do
229
+ D .< do
168
230
  puts "this is executed before every test in this scope"
169
231
  end
170
232
 
171
- # equivalent of after(:each) or teardown()
172
- D.> do
233
+ D .> do
173
234
  puts "this is executed after every test in this scope"
174
235
  end
175
236
 
176
- # equivalent of before(:all)
177
- D.<< do
237
+ D .<< do
178
238
  puts "this is executed once, before all tests in this scope"
179
239
  end
180
240
 
181
- # equivalent of after(:all)
182
- D.>> do
241
+ D .>> do
183
242
  puts "this is executed once, after all tests in this scope"
184
243
  end
185
244
  end