ae 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/{HISTORY.rdoc → HISTORY.md} +48 -18
- data/LICENSE.txt +24 -0
- data/{NOTICE.rdoc → NOTICE.md} +3 -3
- data/{README.rdoc → README.md} +64 -53
- data/{qed/01_overview.rdoc → demo/01_overview.md} +18 -18
- data/{qed/02_assertion.rdoc → demo/02_assertion.md} +1 -1
- data/{qed/03_assert.rdoc → demo/03_assert.md} +126 -124
- data/demo/04_subjunctive.md +100 -0
- data/demo/05_expect.md +104 -0
- data/{qed/06_counts.rdoc → demo/06_counts.md} +13 -13
- data/{qed/07_matchers.rdoc → demo/07_matchers.md} +12 -12
- data/{qed/08_check.rdoc → demo/08_check.md} +20 -22
- data/demo/applique/ae.rb +1 -0
- data/lib/ae/adapters/minitest.rb +31 -36
- data/lib/ae/adapters/testunit.rb +18 -49
- data/lib/ae/assertor.rb +3 -3
- data/lib/ae/core_ext/helpers.rb +1 -1
- data/lib/ae/legacy.rb +12 -0
- data/lib/ae/version.rb +1 -19
- metadata +51 -54
- data/.ruby +0 -48
- data/.yardopts +0 -7
- data/QED.rdoc +0 -736
- data/lib/ae.yml +0 -48
- data/qed/04_subjunctive.rdoc +0 -100
- data/qed/05_expect.rdoc +0 -104
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 23a2b354470346c0cce0e01593887716f750919349cac99c6ec35bdb079a56d7
|
|
4
|
+
data.tar.gz: '013992a3d412b79836902cf8234c3acb6629cfbcf3654e1da51d51144bc43990'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ccfba2d7d7d331f1531810b953c9cf38663f81a3dac682179288c09a8472b510de405034d4bd9334a6872f9a46c96b8e8e94c526b7744c1f20b124b98162aa00
|
|
7
|
+
data.tar.gz: bdfe778a71801e72f005f8f467d3a0cf1f8f0dac106d43fd0c6a146d3ac176d7c6b249dfe3ee437983b733419371d0861e6c6159c2c9e9824600e5bb477ddb36
|
data/{HISTORY.rdoc → HISTORY.md}
RENAMED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
# RELEASE HISTORY
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 1.9.0 / 2026-03-30
|
|
4
|
+
|
|
5
|
+
Maintenance release. Modernized project tooling and cleaned up documentation.
|
|
6
|
+
|
|
7
|
+
Changes:
|
|
8
|
+
|
|
9
|
+
* Replace custom Indexer system with standard gemspec.
|
|
10
|
+
* Replace Travis CI with GitHub Actions.
|
|
11
|
+
* Replace Assembly/detroit with Rakefile.
|
|
12
|
+
* Simplify version.rb to use a plain constant.
|
|
13
|
+
* Update minitest adapter for minitest 5+.
|
|
14
|
+
* Update testunit adapter for modern test-unit gem.
|
|
15
|
+
* Fix typos and update URLs to HTTPS.
|
|
16
|
+
* Add LICENSE.txt.
|
|
17
|
+
* Move site from gh-pages to docs/.
|
|
18
|
+
* Remove obsolete files (var/, etc/, MANIFEST, DEMO.rdoc).
|
|
19
|
+
* Clean up .gitignore.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.8.2 / 2013-02-18
|
|
23
|
+
|
|
24
|
+
This release primarily fixes one bug --the assertions count
|
|
25
|
+
global variable wasn't all caps, which prevented assertions
|
|
26
|
+
from being counted correctly.
|
|
27
|
+
|
|
28
|
+
Changes:
|
|
29
|
+
|
|
30
|
+
* Fix $ASSERTION_COUNTS letter case.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 1.8.1 / 2011-12-04
|
|
4
34
|
|
|
5
35
|
Fixed missing ae/ansi.rb file from distribution.
|
|
6
36
|
|
|
@@ -9,7 +39,7 @@ Changes:
|
|
|
9
39
|
* Update manifest, missing ae/ansi.rb
|
|
10
40
|
|
|
11
41
|
|
|
12
|
-
|
|
42
|
+
## 1.8.0 / 2011-12-03 / Checkered Flag
|
|
13
43
|
|
|
14
44
|
This new release improves support for Proc-based assertions and
|
|
15
45
|
RSpec-style matchers. In addition, this release sees the optional
|
|
@@ -24,7 +54,7 @@ Changes:
|
|
|
24
54
|
* Change licenses to BSD-2-Clause.
|
|
25
55
|
|
|
26
56
|
|
|
27
|
-
|
|
57
|
+
## 1.7.4 / 2011-06-08
|
|
28
58
|
|
|
29
59
|
Quick release fixes an issue due to Ruby 1.9+'s constant look-up
|
|
30
60
|
system. Yes, BasicObject has no clue. This is fixed using the
|
|
@@ -35,7 +65,7 @@ Changes:
|
|
|
35
65
|
* Add const_missing hook to Assertor class to redirect to
|
|
36
66
|
toplevel methods.
|
|
37
67
|
|
|
38
|
-
|
|
68
|
+
## 1.7.3 / 2011-06-06 / D-Day
|
|
39
69
|
|
|
40
70
|
This release simply adds a new optional help library, `ok.rb`.
|
|
41
71
|
The API is still in it's infancy, so it probably will change
|
|
@@ -46,7 +76,7 @@ Changes:
|
|
|
46
76
|
* Add option `ok` helper library.
|
|
47
77
|
|
|
48
78
|
|
|
49
|
-
|
|
79
|
+
## 1.7.2 / 2011-06-02
|
|
50
80
|
|
|
51
81
|
Minor release adds color diffs for failed equality comparisons to
|
|
52
82
|
the error message, and it fixes an issue in which class references
|
|
@@ -61,7 +91,7 @@ Changes:
|
|
|
61
91
|
* Provide ANSI colored diffs for failed equality comparisons.
|
|
62
92
|
|
|
63
93
|
|
|
64
|
-
|
|
94
|
+
## 1.7.1 / 2011-05-06
|
|
65
95
|
|
|
66
96
|
This release adds a specialized message for certain comparison
|
|
67
97
|
operators to allow them have a more forensic output. This is done
|
|
@@ -74,7 +104,7 @@ Changes:
|
|
|
74
104
|
* Remove optional dot.rb and detest.rb emulation scripts.
|
|
75
105
|
|
|
76
106
|
|
|
77
|
-
|
|
107
|
+
## 1.7.0 / 2011-04-28
|
|
78
108
|
|
|
79
109
|
AE now uses proper namespace for all classes. In particular, the `Assertor`
|
|
80
110
|
class has become `AE::Assertor`. Only the `Assertion` class remains outside
|
|
@@ -92,7 +122,7 @@ Changes:
|
|
|
92
122
|
* AE::Assertion class simplified to a simple subclass of Exception.
|
|
93
123
|
|
|
94
124
|
|
|
95
|
-
|
|
125
|
+
## 1.6.1 / 2010-11-05
|
|
96
126
|
|
|
97
127
|
This release has test passing for Ruby 1.9.2. Ruby 1.9.2 doesn't appear
|
|
98
128
|
to like &block and block_given? to be used in same method scope. It
|
|
@@ -104,7 +134,7 @@ Changes:
|
|
|
104
134
|
* Use `&block` and not `block_given?`.
|
|
105
135
|
|
|
106
136
|
|
|
107
|
-
|
|
137
|
+
## 1.6.0 / 2010-11-04
|
|
108
138
|
|
|
109
139
|
Support libraries defining toplevel methods, such as `legacy.rb`, now place
|
|
110
140
|
their methods in AE::World module instead of Object. AE::World needs to
|
|
@@ -118,7 +148,7 @@ Changes:
|
|
|
118
148
|
* In dot.rb `#true!`/`#false!` methods can take an error or error message.
|
|
119
149
|
|
|
120
150
|
|
|
121
|
-
|
|
151
|
+
## 1.5.0 / 2010-09-06
|
|
122
152
|
|
|
123
153
|
This release adds adapters for TestUnit, MiniTest and RSpec. AE worked with
|
|
124
154
|
them previously but AE assertions were seen as errors rather than nice
|
|
@@ -134,7 +164,7 @@ Changes:
|
|
|
134
164
|
* Move final assertion call to Assertion#test.
|
|
135
165
|
|
|
136
166
|
|
|
137
|
-
|
|
167
|
+
## 1.4.0 / 2010-09-02
|
|
138
168
|
|
|
139
169
|
Version 1.4 brings Ruby 1.9 compatibility. The Assertor class is now a
|
|
140
170
|
subclass of BasicObject. This fixes an issues Assertor would had
|
|
@@ -148,7 +178,7 @@ Changes:
|
|
|
148
178
|
* Add #refute= which works like `refute ==`.
|
|
149
179
|
|
|
150
180
|
|
|
151
|
-
|
|
181
|
+
## 1.3.0 / 2010-06-17
|
|
152
182
|
|
|
153
183
|
New release of AE adds support for RSpec-style matchers. This means
|
|
154
184
|
it should be usable with Shoulda 3.0 and any other matchers library.
|
|
@@ -164,7 +194,7 @@ Changes:
|
|
|
164
194
|
* #assert method can do equality comparison.
|
|
165
195
|
|
|
166
196
|
|
|
167
|
-
|
|
197
|
+
## 1.2.3 / 2010-06-07
|
|
168
198
|
|
|
169
199
|
This release is a quick fix, which adds a missing `require 'yaml'`.
|
|
170
200
|
|
|
@@ -173,7 +203,7 @@ Changes:
|
|
|
173
203
|
* Add missing require 'yaml'.
|
|
174
204
|
|
|
175
205
|
|
|
176
|
-
|
|
206
|
+
## 1.2.2 / 2010-06-06
|
|
177
207
|
|
|
178
208
|
Version 1.2.2 simply add one new feature --the ability to
|
|
179
209
|
use 'object.assert = other' instead of 'object.assert == other'.
|
|
@@ -191,7 +221,7 @@ Changes:
|
|
|
191
221
|
* Now distributed under MIT license.
|
|
192
222
|
|
|
193
223
|
|
|
194
|
-
|
|
224
|
+
## 1.2.0 / 2010-01-27
|
|
195
225
|
|
|
196
226
|
This release fixes '=~' assertions and now requires the
|
|
197
227
|
ae/expect library by default.
|
|
@@ -202,7 +232,7 @@ Changes:
|
|
|
202
232
|
* Fixed bug where #=~ did not work correctly against Assertor.
|
|
203
233
|
|
|
204
234
|
|
|
205
|
-
|
|
235
|
+
## 1.1.0 / 2009-09-06
|
|
206
236
|
|
|
207
237
|
This release provided two major improvements. The first is
|
|
208
238
|
the #expect method which is similar to #assert, but uses
|
|
@@ -218,7 +248,7 @@ Changes:
|
|
|
218
248
|
* Added backtrace parameter to flunk calls.
|
|
219
249
|
|
|
220
250
|
|
|
221
|
-
|
|
251
|
+
## 1.0.0 / 2009-09-03
|
|
222
252
|
|
|
223
253
|
This is the initial release of AE.
|
|
224
254
|
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(BSD-2-Clause License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2008 Thomas Sawyer. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
documentation and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
16
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
18
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
19
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
20
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
21
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
22
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
23
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
24
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/{NOTICE.rdoc → NOTICE.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# COPYRIGHT NOTICES
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## AE
|
|
4
4
|
|
|
5
5
|
Copyright:: (c) 2008 Thomas Sawyer
|
|
6
6
|
License: BSD-2-Clause
|
|
@@ -32,7 +32,7 @@ License: BSD-2-Clause
|
|
|
32
32
|
or implied, of Thoams Sawyer.
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## BlankSlate
|
|
36
36
|
|
|
37
37
|
Copyright:: (c) 2004,2006 Jim Weirich
|
|
38
38
|
License:: Custom
|
data/{README.rdoc → README.md}
RENAMED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
# Assertive Expressive
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{bugs}[http://github.com/rubyworks/ae/issues] |
|
|
8
|
-
{mail}[http://googlegroups.com/group/rubyworks-mailinglist]
|
|
3
|
+
[Website](https://rubyworks.github.io/ae) /
|
|
4
|
+
[API](https://rubydoc.info/gems/ae) /
|
|
5
|
+
[Report Issue](https://github.com/rubyworks/ae/issues) /
|
|
6
|
+
[Source Code](https://github.com/rubyworks/ae)
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
[](https://rubygems.org/gems/ae)
|
|
9
|
+
[](https://github.com/rubyworks/ae/actions/workflows/test.yml)
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## About
|
|
14
13
|
|
|
15
14
|
Assertive Expressive (AE) is an assertions framework
|
|
16
15
|
intended for reuse by any TDD, BDD or similar system.
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
## Features
|
|
20
19
|
|
|
21
20
|
* Clear, simple and concise syntax.
|
|
22
21
|
* Uses higher-order functions and fluid notation.
|
|
@@ -24,46 +23,46 @@ intended for reuse by any TDD, BDD or similar system.
|
|
|
24
23
|
* Core extensions are standardized around Ruby Facets.
|
|
25
24
|
* But Facets is not a dependency; the extensions are built-in.
|
|
26
25
|
* Easily extensible allowing for alternate notations.
|
|
27
|
-
* Eats
|
|
26
|
+
* Eats its own dog food.
|
|
28
27
|
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
## Synopsis
|
|
31
30
|
|
|
32
|
-
AE defines the method
|
|
31
|
+
AE defines the method `assert`. It is compatible with the method
|
|
33
32
|
as defined by Test::Unit and MiniTest, which verifies truth of a
|
|
34
33
|
single argument (and can accept an optional failure message).
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
assert(true)
|
|
37
36
|
|
|
38
|
-
In addition AE's
|
|
37
|
+
In addition AE's `assert` method has been extended to accept a block,
|
|
39
38
|
the result of which is likewise verified.
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
assert{true}
|
|
42
41
|
|
|
43
42
|
But the real power the AE's +assert+ method lies in it's use
|
|
44
43
|
without argument or block. In that case it returns an instance of
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
`Assertor`. An `Assertor` is an *Assertions Functor*, or
|
|
45
|
+
*Higher-Order Function*. It is a function that operates on
|
|
47
46
|
another function. With it, we can make assertions like so:
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
x.assert == y
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
a.assert.include? e
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
StandardError.assert.raised? do
|
|
53
|
+
...
|
|
54
|
+
end
|
|
56
55
|
|
|
57
56
|
And so forth. Any method can be used in conjunction with +assert+
|
|
58
57
|
to make an assertion. Eg.
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
class String
|
|
60
|
+
def daffy?
|
|
61
|
+
/daffy/i =~ self
|
|
62
|
+
end
|
|
63
63
|
end
|
|
64
|
-
end
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
"Daffy Duck".assert.daffy?
|
|
67
66
|
|
|
68
67
|
When an assertion fails an Assertion exception is raised. Any test
|
|
69
68
|
framework can catch this exception and process it accordingly.
|
|
@@ -75,10 +74,10 @@ Assertion class.
|
|
|
75
74
|
Please have a look at the QED and API documentation to learn more.
|
|
76
75
|
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
## Integration
|
|
79
78
|
|
|
80
79
|
Generally speaking, AE can be used with any test framework simply by putting
|
|
81
|
-
|
|
80
|
+
`require 'ae'` in a test helper script. However to fully
|
|
82
81
|
integrate with a test framework and ensure the test framework recognizes
|
|
83
82
|
AE assertions (as more than just exceptions) and to ensure assertion
|
|
84
83
|
counts are correct, a little extra interfacing code may be necessary.
|
|
@@ -86,9 +85,9 @@ counts are correct, a little extra interfacing code may be necessary.
|
|
|
86
85
|
Lucky for you AE has already done the leg work for the most common
|
|
87
86
|
test frameworks:
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
require 'ae/adapters/testunit'
|
|
89
|
+
require 'ae/adapters/minitest'
|
|
90
|
+
require 'ae/adapters/rspec'
|
|
92
91
|
|
|
93
92
|
(Note that Cucumber does not need an adapter.)
|
|
94
93
|
|
|
@@ -96,10 +95,10 @@ AE also includes a script that will automatically detect the current
|
|
|
96
95
|
test framework by checking for the existence of their respective
|
|
97
96
|
namespace modules.
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
require 'ae/adapter'
|
|
100
99
|
|
|
101
100
|
|
|
102
|
-
|
|
101
|
+
## Nomenclature
|
|
103
102
|
|
|
104
103
|
With AE, defining assertions centers around the #assert method. So
|
|
105
104
|
*assert* can be thought of as AE's primary _nomenclature_. However, variant
|
|
@@ -107,63 +106,75 @@ nomenclatures have been popularized by other test frameworks, in particular
|
|
|
107
106
|
*should* and *must*. If you prefer one of them terms, AE provides optional
|
|
108
107
|
libraries that can loaded for utilizing them.
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
require 'ae/should'
|
|
110
|
+
require 'ae/must'
|
|
112
111
|
|
|
113
112
|
By loading one of these scripts (or both) into your test system (e.g. via a test
|
|
114
113
|
helper script) you gain access to subjunctive terminology. See the API documentation
|
|
115
114
|
for the Subjunctive module for details.
|
|
116
115
|
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
## Legacy
|
|
119
118
|
|
|
120
119
|
To ease transition from TestUnit style assertion methods, AE provides
|
|
121
120
|
a TestUnit legacy module.
|
|
122
121
|
|
|
123
|
-
|
|
122
|
+
require 'ae/legacy'
|
|
124
123
|
|
|
125
124
|
This provides a module `AE::Legacy::Assertions` which is included in AE::World
|
|
126
125
|
and can be mixed into your test environment to provide old-school assertion
|
|
127
126
|
methods, e.g.
|
|
128
127
|
|
|
129
|
-
|
|
128
|
+
assert_equal(foo, bar, "it failed")
|
|
130
129
|
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
## Installation
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
### Gem Installs
|
|
135
134
|
|
|
136
135
|
Install AE in the usual fashion:
|
|
137
136
|
|
|
138
|
-
|
|
137
|
+
$ gem install ae
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
### Site Installs
|
|
141
140
|
|
|
142
141
|
Local installation requires Setup.rb.
|
|
143
142
|
|
|
144
|
-
|
|
143
|
+
$ gem install setup
|
|
145
144
|
|
|
146
145
|
Then download the tarball package from GitHub
|
|
147
146
|
and do:
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
$ tar -xvzf ae-1.0.0.tgz
|
|
149
|
+
$ cd ae-1.0.0.tgz
|
|
150
|
+
$ sudo setup.rb all
|
|
152
151
|
|
|
153
152
|
Windows users use 'ruby setup.rb all'.
|
|
154
153
|
|
|
155
154
|
|
|
156
|
-
|
|
155
|
+
## Contributing
|
|
156
|
+
|
|
157
|
+
If you would like to contribute code to the AE project, for the upstream
|
|
158
|
+
repository and create a branch for you changes. When your changes are ready
|
|
159
|
+
for review (and no, they do not have to 100% perfect if you still have some issues
|
|
160
|
+
you need help working out).
|
|
161
|
+
|
|
162
|
+
It you need to personally discuss some ideas or issue you try to get up with us
|
|
163
|
+
via the mailing list or the IRC channel.
|
|
164
|
+
|
|
165
|
+
* [Source Code](https://github.com/rubyworks/ae) /
|
|
166
|
+
* [Mailing List](https://groups.google.com/group/rubyworks-mailinglist)
|
|
167
|
+
|
|
157
168
|
|
|
158
|
-
|
|
169
|
+
## Copyrights & License
|
|
159
170
|
|
|
160
|
-
Copyright (c) 2008
|
|
171
|
+
Copyright (c) 2008 Rubyworks. All rights reserved.
|
|
161
172
|
|
|
162
173
|
Unless otherwise provided for by the originating author, this
|
|
163
174
|
program is distributed under the terms of the *BSD-2-Clause* license.
|
|
164
175
|
Portions of this program may be copyrighted by others.
|
|
165
176
|
|
|
166
|
-
See the NOTICE.
|
|
177
|
+
See the NOTICE.md file for details.
|
|
167
178
|
|
|
168
|
-
AE is a Rubyworks
|
|
179
|
+
AE is a [Rubyworks](https://rubyworks.github.io) project.
|
|
169
180
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# Introduction
|
|
2
2
|
|
|
3
3
|
AE is an assertions framework for Ruby. It's designed
|
|
4
4
|
around the concept of an Assertor. The Assertor is an
|
|
@@ -7,11 +7,11 @@ reroutes method calls while monitoring them for failing
|
|
|
7
7
|
conditions.
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## What AE Provides
|
|
11
11
|
|
|
12
12
|
Requiring the AE library.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
require 'ae'
|
|
15
15
|
|
|
16
16
|
Loads two classes, +Assertion+ and +Assertor+, the Kernel
|
|
17
17
|
method +assert+ and it's antonyms +assert!+ and +refute+
|
|
@@ -19,20 +19,20 @@ and a set of core extensions that make writing certain types
|
|
|
19
19
|
of assertions easier.
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## Assertion and Assertor Classes
|
|
23
23
|
|
|
24
24
|
The +Assertion+ class is at the heart of AE. All other AE
|
|
25
25
|
methods depend on it. The +Assertion+ class is a subclass
|
|
26
26
|
of Exception. When an assertion is made and fails, it is
|
|
27
27
|
an instance of Assertion that is raised.
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
expect Assertion do
|
|
30
|
+
msg = "my failure message"
|
|
31
|
+
assert false, msg
|
|
32
|
+
end
|
|
33
33
|
|
|
34
34
|
Like any raised exception, the last Assertion message is available
|
|
35
|
-
via
|
|
35
|
+
via `$!`.
|
|
36
36
|
|
|
37
37
|
(FYI, in Test::Unit the equivalent class was called +AssertionFailedError+.)
|
|
38
38
|
|
|
@@ -46,26 +46,26 @@ invocation to monitor for failed conditions, upon which is raises
|
|
|
46
46
|
Assertion exceptions.
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
## Assertion Methods
|
|
50
50
|
|
|
51
51
|
The three methods, +assert+, <tt>assert!</tt> and +refute+ all
|
|
52
52
|
return an Assertor instance when used fluidly, i.e. magic-dot
|
|
53
53
|
notation, higher-order notation, functor notation, whatever you
|
|
54
54
|
prefer to call it.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
assert(AE::Assertor === assert)
|
|
57
57
|
|
|
58
58
|
Through the use of +method_missing+, the Assertor allows us to write
|
|
59
59
|
statements like:
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
1.assert == 1
|
|
62
62
|
|
|
63
63
|
If the operation evaluates to false or nil, then an Assertion error
|
|
64
64
|
is raised.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
expect Assertion do
|
|
67
|
+
1.assert == 2
|
|
68
|
+
end
|
|
69
69
|
|
|
70
70
|
The methods <tt>assert!</tt> and +refute+ are just like +assert+
|
|
71
71
|
expect they purport the negative condition. Patterned after Ruby's
|
|
@@ -74,7 +74,7 @@ read "assert not". While +refute+ exists for the sake of those who
|
|
|
74
74
|
find the use of a bang method for this purpose unsuited to them.
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
## How It Works
|
|
78
78
|
|
|
79
79
|
An Assertor essentially sits in wait for a method call (via
|
|
80
80
|
method_missing). When that happens it applies the method to the
|
|
@@ -82,11 +82,11 @@ original receiver, but wrapped in a clause that raises an
|
|
|
82
82
|
Assertion should the statement fail. If we wanted to be
|
|
83
83
|
pedantic, we could write our assertions like:
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
raise Assertion.new("1 != 1") unless 1 == 1
|
|
86
86
|
|
|
87
87
|
Instead of
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
1.assert == 1
|
|
90
90
|
|
|
91
91
|
Obviously using Assertor methods are whole lot more concise.
|
|
92
92
|
|