fluidity 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.index +56 -0
- data/.ruby +1 -51
- data/DEMOS.md +197 -0
- data/HISTORY.md +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/demo/00_intro.md +2 -0
- data/demo/01_should.md +52 -0
- data/demo/02_must.md +58 -0
- data/demo/03_assert.md +56 -0
- data/demo/04_other.md +25 -0
- data/lib/fluidity.yml +38 -33
- data/lib/fluidity/about.rb +9 -9
- data/lib/fluidity/assert.rb +6 -3
- data/lib/fluidity/must.rb +6 -0
- data/lib/fluidity/should.rb +2 -0
- data/lib/fluidity/will.rb +36 -0
- metadata +43 -19
- data/spec/01_should.rdoc +0 -52
- data/spec/02_must.rdoc +0 -58
- data/spec/03_assert.rdoc +0 -56
- data/spec/04_other.rdoc +0 -24
data/.index
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
type: ruby
|
3
|
+
revision: 2013
|
4
|
+
sources:
|
5
|
+
- var
|
6
|
+
authors:
|
7
|
+
- name: Thomas Sawyer
|
8
|
+
email: transfire@gmail.com
|
9
|
+
organizations: []
|
10
|
+
requirements:
|
11
|
+
- name: assay
|
12
|
+
- groups:
|
13
|
+
- build
|
14
|
+
development: true
|
15
|
+
name: detroit
|
16
|
+
- groups:
|
17
|
+
- test
|
18
|
+
development: true
|
19
|
+
name: qed
|
20
|
+
conflicts: []
|
21
|
+
alternatives: []
|
22
|
+
resources:
|
23
|
+
- type: home
|
24
|
+
uri: http://rubyworks.github.com/fluidity
|
25
|
+
label: Homepage
|
26
|
+
- type: docs
|
27
|
+
uri: http://rubydoc.info/gems/fluidity
|
28
|
+
label: Documentation
|
29
|
+
- type: code
|
30
|
+
uri: http://github.com/rubyworks/fluidity
|
31
|
+
label: Source Code
|
32
|
+
- type: mail
|
33
|
+
uri: http://groups.google.com/groups/rubyworks-mailinglist
|
34
|
+
label: Mailing List
|
35
|
+
repositories:
|
36
|
+
- name: upstream
|
37
|
+
scm: git
|
38
|
+
uri: git@github.com:rubyworks/fluidity.git
|
39
|
+
categories: []
|
40
|
+
paths:
|
41
|
+
load:
|
42
|
+
- lib
|
43
|
+
copyrights:
|
44
|
+
- holder: Thomas Sawyer
|
45
|
+
year: '2012'
|
46
|
+
license: BSD-2-Clause
|
47
|
+
created: '2012-01-18'
|
48
|
+
summary: Fluid Validity
|
49
|
+
title: Fluidity
|
50
|
+
version: 0.1.1
|
51
|
+
name: fluidity
|
52
|
+
description: ! 'Fluidity is a test assertions framework built on top of the Assay
|
53
|
+
assertions
|
54
|
+
|
55
|
+
meta-framework. It provides an elegant fluid notation for specifying test assertions.'
|
56
|
+
date: '2012-12-21'
|
data/.ruby
CHANGED
@@ -1,51 +1 @@
|
|
1
|
-
|
2
|
-
source:
|
3
|
-
- meta
|
4
|
-
- .ruby
|
5
|
-
authors:
|
6
|
-
- name: Thomas Sawyer
|
7
|
-
email: transfire@gmail.com
|
8
|
-
copyrights:
|
9
|
-
- holder: Thomas Sawyer
|
10
|
-
year: '2012'
|
11
|
-
license: BSD-2-Clause
|
12
|
-
replacements: []
|
13
|
-
alternatives: []
|
14
|
-
requirements:
|
15
|
-
- name: assay
|
16
|
-
- name: detroit
|
17
|
-
groups:
|
18
|
-
- build
|
19
|
-
development: true
|
20
|
-
- name: qed
|
21
|
-
groups:
|
22
|
-
- test
|
23
|
-
development: true
|
24
|
-
dependencies: []
|
25
|
-
conflicts: []
|
26
|
-
repositories:
|
27
|
-
- uri: git@github.com:rubyworks/fluidity.git
|
28
|
-
scm: git
|
29
|
-
name: upstream
|
30
|
-
resources:
|
31
|
-
home: http://rubyworks.github.com/fluidity
|
32
|
-
docs: http://rubydoc.info/gems/fluidity
|
33
|
-
code: http://github.com/rubyworks/fluidity
|
34
|
-
mail: http://groups.google.com/groups/rubyworks-mailinglist
|
35
|
-
extra: {}
|
36
|
-
load_path:
|
37
|
-
- lib
|
38
|
-
revision: 0
|
39
|
-
created: '2012-01-18'
|
40
|
-
summary: Fluid Validity
|
41
|
-
title: Fluidity
|
42
|
-
version: 0.1.0
|
43
|
-
name: fluidity
|
44
|
-
description: ! 'Fluidity is an assertions grammer built on top of the Assay assertions
|
45
|
-
framework.
|
46
|
-
|
47
|
-
It defines a set of methods which provide a fluid notation for specifying
|
48
|
-
|
49
|
-
test assertions.'
|
50
|
-
organization: Rubyworks
|
51
|
-
date: '2012-01-27'
|
1
|
+
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
|
data/DEMOS.md
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
= Fluidity
|
2
|
+
|
3
|
+
|
4
|
+
== Should
|
5
|
+
|
6
|
+
require 'fluidity/should'
|
7
|
+
|
8
|
+
Now we have a fluent notation with which to make assertions.
|
9
|
+
|
10
|
+
true.should.be.true
|
11
|
+
false.should.be.false
|
12
|
+
|
13
|
+
(5 + 5).should.equal 10
|
14
|
+
|
15
|
+
[1,2,3].should.include(2)
|
16
|
+
|
17
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
18
|
+
|
19
|
+
false.should.be.false?
|
20
|
+
true.should.be.true?
|
21
|
+
|
22
|
+
(5 + 5).should == 10
|
23
|
+
|
24
|
+
Indefinite article `a` and `an` are suppored.
|
25
|
+
|
26
|
+
12.should.be.a.kind_of?(Integer)
|
27
|
+
|
28
|
+
As is `not` for negation.
|
29
|
+
|
30
|
+
12.should.not.equal(20)
|
31
|
+
|
32
|
+
We should also make sure such assertions can fail.
|
33
|
+
|
34
|
+
IncludeAssay.should.be.raised do
|
35
|
+
[1,2,3].should.include(4)
|
36
|
+
end
|
37
|
+
|
38
|
+
FalseAssay.should.be.raised do
|
39
|
+
true.should.be.false
|
40
|
+
end
|
41
|
+
|
42
|
+
EqualAssay.should.be.raised do
|
43
|
+
(5 + 5).should == 11
|
44
|
+
end
|
45
|
+
|
46
|
+
Matcher notation is also supported, if you have any matcher classes
|
47
|
+
to use. Assay classes can be converted to matchers, so we can use
|
48
|
+
one of those to try this out.
|
49
|
+
|
50
|
+
be_sixteen = EqualAssay[16.0]
|
51
|
+
|
52
|
+
16.should be_sixteen
|
53
|
+
|
54
|
+
15.should_not be_sixteen
|
55
|
+
|
56
|
+
|
57
|
+
== Must
|
58
|
+
|
59
|
+
require 'fluidity/must'
|
60
|
+
|
61
|
+
Now we have a fluent notation with which to make assertions.
|
62
|
+
|
63
|
+
true.must.be.true
|
64
|
+
false.must.be.false
|
65
|
+
|
66
|
+
(5 + 5).must.equal 10
|
67
|
+
|
68
|
+
[1,2,3].must.include(2)
|
69
|
+
|
70
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
71
|
+
|
72
|
+
false.must.be.false?
|
73
|
+
true.must.be.true?
|
74
|
+
|
75
|
+
(5 + 5).must == 10
|
76
|
+
|
77
|
+
Indefinite article `a` and `an` are suppored.
|
78
|
+
|
79
|
+
12.must.be.a.kind_of?(Integer)
|
80
|
+
|
81
|
+
12.must.be.an.instance_of?(Fixnum)
|
82
|
+
|
83
|
+
As is `not` for negation.
|
84
|
+
|
85
|
+
12.must.not.equal(20)
|
86
|
+
|
87
|
+
Or `must_not` can also be used.
|
88
|
+
|
89
|
+
12.must_not.equal(20)
|
90
|
+
|
91
|
+
We must also make sure such assertions can fail.
|
92
|
+
|
93
|
+
IncludeAssay.must.be.raised do
|
94
|
+
[1,2,3].must.include(4)
|
95
|
+
end
|
96
|
+
|
97
|
+
FalseAssay.must.be.raised do
|
98
|
+
true.must.be.false
|
99
|
+
end
|
100
|
+
|
101
|
+
EqualAssay.must.be.raised do
|
102
|
+
(5 + 5).must == 11
|
103
|
+
end
|
104
|
+
|
105
|
+
Matcher notation is also supported, if you have any matcher classes
|
106
|
+
to use. Assay classes can be converted to matchers, so we can use
|
107
|
+
one of those to try this out.
|
108
|
+
|
109
|
+
be_sixteen = EqualAssay[16.0]
|
110
|
+
|
111
|
+
16.must be_sixteen
|
112
|
+
|
113
|
+
15.must_not be_sixteen
|
114
|
+
|
115
|
+
|
116
|
+
= Grammer
|
117
|
+
|
118
|
+
require 'fluidity/assert'
|
119
|
+
|
120
|
+
Now we have a fluent notation with which to make assertions.
|
121
|
+
|
122
|
+
true.assert.true
|
123
|
+
false.assert.false
|
124
|
+
|
125
|
+
(5 + 5).must.equal 10
|
126
|
+
|
127
|
+
[1,2,3].must.include(2)
|
128
|
+
|
129
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
130
|
+
|
131
|
+
false.assert.false?
|
132
|
+
true.assert.true?
|
133
|
+
|
134
|
+
(5 + 5).assert == 10
|
135
|
+
|
136
|
+
(9 + 9).assert.not == 10
|
137
|
+
|
138
|
+
12.assert.kind_of?(Integer)
|
139
|
+
|
140
|
+
As is `not` for negation.
|
141
|
+
|
142
|
+
12.assert.not.equal(20)
|
143
|
+
|
144
|
+
Or `should_not` can also be used.
|
145
|
+
|
146
|
+
12.should_not.equal(20)
|
147
|
+
|
148
|
+
We must also make sure such assertions can fail. Since #assert is special
|
149
|
+
method to assay classes, we can use it as on these as part of our test
|
150
|
+
grmmer. So we use the raw `#assert!` method to handle the test.
|
151
|
+
|
152
|
+
RaiseAssay.assert!(IncludeAssay) do
|
153
|
+
[1,2,3].assert.include(4)
|
154
|
+
end
|
155
|
+
|
156
|
+
RaiseAssay.assert!(FalseAssay) do
|
157
|
+
true.assert.false
|
158
|
+
end
|
159
|
+
|
160
|
+
RaiseAssay.assert!(EqualityAssay) do
|
161
|
+
(5 + 5).assert == 11
|
162
|
+
end
|
163
|
+
|
164
|
+
Matcher notation is also supported, if you have any matcher classes
|
165
|
+
to use. Assay classes can be converted to matchers, so we can use
|
166
|
+
one of those to try this out.
|
167
|
+
|
168
|
+
is_sixteen = EqualityAssay[16.0]
|
169
|
+
|
170
|
+
16.assert is_sixteen
|
171
|
+
|
172
|
+
|
173
|
+
== Other Stuff
|
174
|
+
|
175
|
+
What if there is an assertion made for which no Assay class exists?
|
176
|
+
If the target object has a query method defined by the same name,
|
177
|
+
that is, one ending in a `?` mark, then that mehtod will be used
|
178
|
+
to test the assertion.
|
179
|
+
|
180
|
+
c = Class.new do
|
181
|
+
def initialize(truth)
|
182
|
+
@truth = truth
|
183
|
+
end
|
184
|
+
def yes?
|
185
|
+
@truth
|
186
|
+
end
|
187
|
+
def no?
|
188
|
+
!@truth
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
x = c.new(true)
|
193
|
+
|
194
|
+
x.should.be.yes
|
195
|
+
|
196
|
+
x.should_not.be.no
|
197
|
+
|
data/HISTORY.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# HISTORY
|
2
|
+
|
3
|
+
## 0.1.1 / 2012-12-21
|
4
|
+
|
5
|
+
Fix bug in #assert nomenclature method, and add support for
|
6
|
+
both #shouldnt and #musnt in their respective files.
|
7
|
+
|
8
|
+
Changes:
|
9
|
+
|
10
|
+
* Fix matcher check in #assert.
|
11
|
+
* Add #shouldnt as alias for #should_not.
|
12
|
+
* Add #musnt as alias for #must_not.
|
13
|
+
|
14
|
+
|
15
|
+
## 0.1.0 / 2012-01-27
|
16
|
+
|
17
|
+
This is the initial release of Fluidity.
|
18
|
+
|
19
|
+
Changes:
|
20
|
+
|
21
|
+
* Happy Birthday!
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
BSD-2-Clause License
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
11
|
+
documentation and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
14
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
16
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
17
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
18
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
19
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
20
|
+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
21
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
22
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Fluidity
|
2
|
+
|
3
|
+
[Website](http://rubyworks.github.com/fluidity) /
|
4
|
+
[Report Issue](http://github.com/rubyworks/fluidity/issues) /
|
5
|
+
[Source Code](http://github.com/rubyworks/fluidity)
|
6
|
+
( [![Build Status](https://secure.travis-ci.org/rubyworks/fluidity.png)](http://travis-ci.org/rubyworks/fluidity) )
|
7
|
+
|
8
|
+
<br/>
|
9
|
+
|
10
|
+
Fluidity is an assertions framework that provides a very elegant fluid
|
11
|
+
notation for specifying test assertions.
|
12
|
+
|
13
|
+
Fluidity is built on top of the [Assay](http://rubyworks.github.com/assay)
|
14
|
+
assertions meta-framework, giving it a solid foundation. Assay defines
|
15
|
+
assertions in the same way that Ruby defines exceptions. Assay provides
|
16
|
+
a complete set of these assertion classes for all common assertion needs.
|
17
|
+
|
18
|
+
|
19
|
+
## Instruction
|
20
|
+
|
21
|
+
Developers want to write assertions easily and concisely. To this end Fluidity
|
22
|
+
provides a flexible grammar system which can be used by requiring any of the
|
23
|
+
prime grammar methods that extend Object. The most common is probably `should`.
|
24
|
+
|
25
|
+
require 'fluidity/should'
|
26
|
+
|
27
|
+
10.should.be.kind_of(Integer)
|
28
|
+
|
29
|
+
But if you are accustom to MiniTest's spec methods, you might prefer `must`.
|
30
|
+
|
31
|
+
require 'fluidity/must'
|
32
|
+
|
33
|
+
10.must.be.kind_of(Integer)
|
34
|
+
|
35
|
+
Also provided is `assert` for those techy aficionados.
|
36
|
+
|
37
|
+
require 'fluidity/assert'
|
38
|
+
|
39
|
+
10.assert.kind_of(Integer)
|
40
|
+
|
41
|
+
So what is so fluid about all this? Well, Fluidity allows the developer quite
|
42
|
+
the English like expression. For instance.
|
43
|
+
|
44
|
+
10.should.not.be.an.instance_of?(String)
|
45
|
+
|
46
|
+
Pretty neat, though perhaps bit excessive for a real-life use. Generally
|
47
|
+
it's good enough to use the shorter and a tad bit faster:
|
48
|
+
|
49
|
+
10.shouldnt.be.instance_of?(String)
|
50
|
+
|
51
|
+
Speaking of _fast_, so what about speed? Of course, running through multiple
|
52
|
+
extra method calls to make an assertion is going to be slower than making just
|
53
|
+
a single method call. So, yes, tests might run a bit slower on Fluidity than
|
54
|
+
they would with another less readable assertions system. However, method calls
|
55
|
+
are pretty dang fast and unlikely to present any significant performance
|
56
|
+
overhead on test runs. At most, tests runs might take a few additional seconds
|
57
|
+
for _very_ _large_ test suites.
|
58
|
+
|
59
|
+
|
60
|
+
## Installation
|
61
|
+
|
62
|
+
To install with RubyGems simply open a console and type:
|
63
|
+
|
64
|
+
gem install fluidity
|
65
|
+
|
66
|
+
Site installation with the tarball can be done with Ruby Setup
|
67
|
+
(gem install setup). See http://rubyworks.github.com/setup.
|
68
|
+
|
69
|
+
|
70
|
+
## Copyrights
|
71
|
+
|
72
|
+
Fluidity is copyrighted open source software.
|
73
|
+
|
74
|
+
Copyright (c) 2012 Rubyworks
|
75
|
+
|
76
|
+
This program can be modified and distributed in accordance with
|
77
|
+
the terms of the [BSD-2-Clause](http://spdx.org/licenses/BSD-2-Clause) license.
|
78
|
+
|
79
|
+
See LICENSE.txt file for details.
|
data/demo/00_intro.md
ADDED
data/demo/01_should.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
## Should
|
2
|
+
|
3
|
+
require 'fluidity/should'
|
4
|
+
|
5
|
+
Now we have a fluent notation with which to make assertions.
|
6
|
+
|
7
|
+
true.should.be.true
|
8
|
+
false.should.be.false
|
9
|
+
|
10
|
+
(5 + 5).should.equal 10
|
11
|
+
|
12
|
+
[1,2,3].should.include(2)
|
13
|
+
|
14
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
+
|
16
|
+
false.should.be.false?
|
17
|
+
true.should.be.true?
|
18
|
+
|
19
|
+
(5 + 5).should == 10
|
20
|
+
|
21
|
+
Indefinite article `a` and `an` are suppored.
|
22
|
+
|
23
|
+
12.should.be.a.kind_of?(Integer)
|
24
|
+
|
25
|
+
As is `not` for negation.
|
26
|
+
|
27
|
+
12.should.not.equal(20)
|
28
|
+
|
29
|
+
We should also make sure such assertions can fail.
|
30
|
+
|
31
|
+
IncludeAssay.should.be.raised do
|
32
|
+
[1,2,3].should.include(4)
|
33
|
+
end
|
34
|
+
|
35
|
+
FalseAssay.should.be.raised do
|
36
|
+
true.should.be.false
|
37
|
+
end
|
38
|
+
|
39
|
+
EqualAssay.should.be.raised do
|
40
|
+
(5 + 5).should == 11
|
41
|
+
end
|
42
|
+
|
43
|
+
Matcher notation is also supported, if you have any matcher classes
|
44
|
+
to use. Assay classes can be converted to matchers, so we can use
|
45
|
+
one of those to try this out.
|
46
|
+
|
47
|
+
be_sixteen = EqualAssay[16.0]
|
48
|
+
|
49
|
+
16.should be_sixteen
|
50
|
+
|
51
|
+
15.should_not be_sixteen
|
52
|
+
|
data/demo/02_must.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
## Must
|
2
|
+
|
3
|
+
require 'fluidity/must'
|
4
|
+
|
5
|
+
Now we have a fluent notation with which to make assertions.
|
6
|
+
|
7
|
+
true.must.be.true
|
8
|
+
false.must.be.false
|
9
|
+
|
10
|
+
(5 + 5).must.equal 10
|
11
|
+
|
12
|
+
[1,2,3].must.include(2)
|
13
|
+
|
14
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
+
|
16
|
+
false.must.be.false?
|
17
|
+
true.must.be.true?
|
18
|
+
|
19
|
+
(5 + 5).must == 10
|
20
|
+
|
21
|
+
Indefinite article `a` and `an` are suppored.
|
22
|
+
|
23
|
+
12.must.be.a.kind_of?(Integer)
|
24
|
+
|
25
|
+
12.must.be.an.instance_of?(Fixnum)
|
26
|
+
|
27
|
+
As is `not` for negation.
|
28
|
+
|
29
|
+
12.must.not.equal(20)
|
30
|
+
|
31
|
+
Or `must_not` can also be used.
|
32
|
+
|
33
|
+
12.must_not.equal(20)
|
34
|
+
|
35
|
+
We must also make sure such assertions can fail.
|
36
|
+
|
37
|
+
IncludeAssay.must.be.raised do
|
38
|
+
[1,2,3].must.include(4)
|
39
|
+
end
|
40
|
+
|
41
|
+
FalseAssay.must.be.raised do
|
42
|
+
true.must.be.false
|
43
|
+
end
|
44
|
+
|
45
|
+
EqualAssay.must.be.raised do
|
46
|
+
(5 + 5).must == 11
|
47
|
+
end
|
48
|
+
|
49
|
+
Matcher notation is also supported, if you have any matcher classes
|
50
|
+
to use. Assay classes can be converted to matchers, so we can use
|
51
|
+
one of those to try this out.
|
52
|
+
|
53
|
+
be_sixteen = EqualAssay[16.0]
|
54
|
+
|
55
|
+
16.must be_sixteen
|
56
|
+
|
57
|
+
15.must_not be_sixteen
|
58
|
+
|
data/demo/03_assert.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
## Grammer
|
2
|
+
|
3
|
+
require 'fluidity/assert'
|
4
|
+
|
5
|
+
Now we have a fluent notation with which to make assertions.
|
6
|
+
|
7
|
+
true.assert.true
|
8
|
+
false.assert.false
|
9
|
+
|
10
|
+
(5 + 5).must.equal 10
|
11
|
+
|
12
|
+
[1,2,3].must.include(2)
|
13
|
+
|
14
|
+
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
+
|
16
|
+
false.assert.false?
|
17
|
+
true.assert.true?
|
18
|
+
|
19
|
+
(5 + 5).assert == 10
|
20
|
+
|
21
|
+
(9 + 9).assert.not == 10
|
22
|
+
|
23
|
+
12.assert.kind_of?(Integer)
|
24
|
+
|
25
|
+
As is `not` for negation.
|
26
|
+
|
27
|
+
12.assert.not.equal(20)
|
28
|
+
|
29
|
+
Or `should_not` can also be used.
|
30
|
+
|
31
|
+
12.should_not.equal(20)
|
32
|
+
|
33
|
+
We must also make sure such assertions can fail. Since #assert is special
|
34
|
+
method to assay classes, we can use it as on these as part of our test
|
35
|
+
grmmer. So we use the raw `#assert!` method to handle the test.
|
36
|
+
|
37
|
+
RaiseAssay.assert!(IncludeAssay) do
|
38
|
+
[1,2,3].assert.include(4)
|
39
|
+
end
|
40
|
+
|
41
|
+
RaiseAssay.assert!(FalseAssay) do
|
42
|
+
true.assert.false
|
43
|
+
end
|
44
|
+
|
45
|
+
RaiseAssay.assert!(EqualityAssay) do
|
46
|
+
(5 + 5).assert == 11
|
47
|
+
end
|
48
|
+
|
49
|
+
Matcher notation is also supported, if you have any matcher classes
|
50
|
+
to use. Assay classes can be converted to matchers, so we can use
|
51
|
+
one of those to try this out.
|
52
|
+
|
53
|
+
is_sixteen = EqualityAssay[16.0]
|
54
|
+
|
55
|
+
16.assert is_sixteen
|
56
|
+
|
data/demo/04_other.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## Other Stuff
|
2
|
+
|
3
|
+
What if there is an assertion made for which no Assay class exists?
|
4
|
+
If the target object has a query method defined by the same name,
|
5
|
+
that is, one ending in a `?` mark, then that mehtod will be used
|
6
|
+
to test the assertion.
|
7
|
+
|
8
|
+
c = Class.new do
|
9
|
+
def initialize(truth)
|
10
|
+
@truth = truth
|
11
|
+
end
|
12
|
+
def yes?
|
13
|
+
@truth
|
14
|
+
end
|
15
|
+
def no?
|
16
|
+
!@truth
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
x = c.new(true)
|
21
|
+
|
22
|
+
x.should.be.yes
|
23
|
+
|
24
|
+
x.should_not.be.no
|
25
|
+
|
data/lib/fluidity.yml
CHANGED
@@ -1,51 +1,56 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
type: ruby
|
3
|
+
revision: 2013
|
4
|
+
sources:
|
5
|
+
- var
|
5
6
|
authors:
|
6
7
|
- name: Thomas Sawyer
|
7
8
|
email: transfire@gmail.com
|
8
|
-
|
9
|
-
- holder: Thomas Sawyer
|
10
|
-
year: '2012'
|
11
|
-
license: BSD-2-Clause
|
12
|
-
replacements: []
|
13
|
-
alternatives: []
|
9
|
+
organizations: []
|
14
10
|
requirements:
|
15
11
|
- name: assay
|
16
|
-
-
|
17
|
-
groups:
|
12
|
+
- groups:
|
18
13
|
- build
|
19
14
|
development: true
|
20
|
-
|
21
|
-
|
15
|
+
name: detroit
|
16
|
+
- groups:
|
22
17
|
- test
|
23
18
|
development: true
|
24
|
-
|
19
|
+
name: qed
|
25
20
|
conflicts: []
|
21
|
+
alternatives: []
|
22
|
+
resources:
|
23
|
+
- type: home
|
24
|
+
uri: http://rubyworks.github.com/fluidity
|
25
|
+
label: Homepage
|
26
|
+
- type: docs
|
27
|
+
uri: http://rubydoc.info/gems/fluidity
|
28
|
+
label: Documentation
|
29
|
+
- type: code
|
30
|
+
uri: http://github.com/rubyworks/fluidity
|
31
|
+
label: Source Code
|
32
|
+
- type: mail
|
33
|
+
uri: http://groups.google.com/groups/rubyworks-mailinglist
|
34
|
+
label: Mailing List
|
26
35
|
repositories:
|
27
|
-
-
|
36
|
+
- name: upstream
|
28
37
|
scm: git
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
-
|
38
|
-
revision: 0
|
38
|
+
uri: git@github.com:rubyworks/fluidity.git
|
39
|
+
categories: []
|
40
|
+
paths:
|
41
|
+
load:
|
42
|
+
- lib
|
43
|
+
copyrights:
|
44
|
+
- holder: Thomas Sawyer
|
45
|
+
year: '2012'
|
46
|
+
license: BSD-2-Clause
|
39
47
|
created: '2012-01-18'
|
40
48
|
summary: Fluid Validity
|
41
49
|
title: Fluidity
|
42
|
-
version: 0.1.
|
50
|
+
version: 0.1.1
|
43
51
|
name: fluidity
|
44
|
-
description: ! 'Fluidity is
|
45
|
-
|
46
|
-
|
47
|
-
It defines a set of methods which provide a fluid notation for specifying
|
52
|
+
description: ! 'Fluidity is a test assertions framework built on top of the Assay
|
53
|
+
assertions
|
48
54
|
|
49
|
-
test assertions.'
|
50
|
-
|
51
|
-
date: '2012-01-27'
|
55
|
+
meta-framework. It provides an elegant fluid notation for specifying test assertions.'
|
56
|
+
date: '2012-12-21'
|
data/lib/fluidity/about.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Fluidity
|
2
2
|
|
3
|
-
# Access to metadata.
|
4
|
-
def self.metadata
|
5
|
-
@metadata ||= (
|
6
|
-
require 'yaml'
|
7
|
-
YAML.load(File.new(File.dirname(__FILE__) + '/../fluidity.yml'))
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
3
|
# Access to project metadata as constants.
|
12
4
|
def self.const_missing(name)
|
13
5
|
key = name.to_s.downcase
|
14
|
-
|
6
|
+
index[key] || super(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Access to project metadata.
|
10
|
+
def self.index
|
11
|
+
@metadata ||= (
|
12
|
+
require 'yaml'
|
13
|
+
YAML.load_file(File.dirname(__FILE__) + '/../fluidity.yml')
|
14
|
+
)
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/lib/fluidity/assert.rb
CHANGED
@@ -6,10 +6,13 @@ class Object
|
|
6
6
|
#
|
7
7
|
# 10.assert.kind_of?(Integer)
|
8
8
|
#
|
9
|
-
def assert(matcher=nil, *args)
|
9
|
+
def assert(matcher=nil, *args, &blk)
|
10
10
|
if matcher
|
11
|
-
|
12
|
-
|
11
|
+
if matcher.respond_to?(:=~) # good enough ?
|
12
|
+
matcher =~ self
|
13
|
+
else
|
14
|
+
super(matcher, *args, &blk)
|
15
|
+
end
|
13
16
|
else
|
14
17
|
::Fluidity::Grammer::Assert.new(self)
|
15
18
|
end
|
data/lib/fluidity/must.rb
CHANGED
data/lib/fluidity/should.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fluidity/grammer'
|
2
|
+
|
3
|
+
class Object #BasicObject
|
4
|
+
|
5
|
+
# Use `will` nomenclature for assertions.
|
6
|
+
#
|
7
|
+
# 10.will.be.kind_of(Integer)
|
8
|
+
#
|
9
|
+
def will(matcher=nil)
|
10
|
+
if matcher
|
11
|
+
matcher =~ self
|
12
|
+
else
|
13
|
+
::Fluidity::Grammer::Must.new(self)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Also, `will_not` nomenclature for assertions.
|
18
|
+
#
|
19
|
+
# 10.will_not.be.kind_of?(Integer)
|
20
|
+
#
|
21
|
+
def must_not(matcher=nil)
|
22
|
+
if matcher
|
23
|
+
matcher !~ self
|
24
|
+
else
|
25
|
+
::Fluidity::Grammer::Must.new(self, true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Contraction of will not.
|
30
|
+
#
|
31
|
+
# 10.wont.be.kind_of?(Integer)
|
32
|
+
#
|
33
|
+
alias_method :wont, :will_not
|
34
|
+
|
35
|
+
end
|
36
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluidity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: assay
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: detroit
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: qed
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,32 +53,46 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ! 'Fluidity is a test assertions framework built on top of the Assay
|
63
|
+
assertions
|
51
64
|
|
52
|
-
test assertions.'
|
65
|
+
meta-framework. It provides an elegant fluid notation for specifying test assertions.'
|
53
66
|
email:
|
54
67
|
- transfire@gmail.com
|
55
68
|
executables: []
|
56
69
|
extensions: []
|
57
|
-
extra_rdoc_files:
|
70
|
+
extra_rdoc_files:
|
71
|
+
- LICENSE.txt
|
72
|
+
- HISTORY.md
|
73
|
+
- README.md
|
74
|
+
- DEMOS.md
|
58
75
|
files:
|
76
|
+
- .index
|
59
77
|
- .ruby
|
78
|
+
- demo/00_intro.md
|
79
|
+
- demo/01_should.md
|
80
|
+
- demo/02_must.md
|
81
|
+
- demo/03_assert.md
|
82
|
+
- demo/04_other.md
|
60
83
|
- lib/fluidity/about.rb
|
61
84
|
- lib/fluidity/assert.rb
|
62
85
|
- lib/fluidity/grammer.rb
|
63
86
|
- lib/fluidity/is.rb
|
64
87
|
- lib/fluidity/must.rb
|
65
88
|
- lib/fluidity/should.rb
|
89
|
+
- lib/fluidity/will.rb
|
66
90
|
- lib/fluidity.rb
|
67
91
|
- lib/fluidity.yml
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
92
|
+
- LICENSE.txt
|
93
|
+
- HISTORY.md
|
94
|
+
- README.md
|
95
|
+
- DEMOS.md
|
72
96
|
homepage: http://rubyworks.github.com/fluidity
|
73
97
|
licenses:
|
74
98
|
- BSD-2-Clause
|
@@ -90,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
114
|
version: '0'
|
91
115
|
requirements: []
|
92
116
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.23
|
94
118
|
signing_key:
|
95
119
|
specification_version: 3
|
96
120
|
summary: Fluid Validity
|
data/spec/01_should.rdoc
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
== Should
|
2
|
-
|
3
|
-
require 'fluidity/should'
|
4
|
-
|
5
|
-
Now we have a fluent notation with which to make assertions.
|
6
|
-
|
7
|
-
true.should.be.true
|
8
|
-
false.should.be.false
|
9
|
-
|
10
|
-
(5 + 5).should.equal 10
|
11
|
-
|
12
|
-
[1,2,3].should.include(2)
|
13
|
-
|
14
|
-
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
-
|
16
|
-
false.should.be.false?
|
17
|
-
true.should.be.true?
|
18
|
-
|
19
|
-
(5 + 5).should == 10
|
20
|
-
|
21
|
-
Indefinite article `a` and `an` are suppored.
|
22
|
-
|
23
|
-
12.should.be.a.kind_of?(Integer)
|
24
|
-
|
25
|
-
As is `not` for negation.
|
26
|
-
|
27
|
-
12.should.not.equal(20)
|
28
|
-
|
29
|
-
We should also make sure such assertions can fail.
|
30
|
-
|
31
|
-
IncludeAssay.should.be.raised do
|
32
|
-
[1,2,3].should.include(4)
|
33
|
-
end
|
34
|
-
|
35
|
-
FalseAssay.should.be.raised do
|
36
|
-
true.should.be.false
|
37
|
-
end
|
38
|
-
|
39
|
-
EqualAssay.should.be.raised do
|
40
|
-
(5 + 5).should == 11
|
41
|
-
end
|
42
|
-
|
43
|
-
Matcher notation is also supported, if you have any matcher classes
|
44
|
-
to use. Assay classes can be converted to matchers, so we can use
|
45
|
-
one of those to try this out.
|
46
|
-
|
47
|
-
be_sixteen = EqualAssay[16.0]
|
48
|
-
|
49
|
-
16.should be_sixteen
|
50
|
-
|
51
|
-
15.should_not be_sixteen
|
52
|
-
|
data/spec/02_must.rdoc
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
== Must
|
2
|
-
|
3
|
-
require 'fluidity/must'
|
4
|
-
|
5
|
-
Now we have a fluent notation with which to make assertions.
|
6
|
-
|
7
|
-
true.must.be.true
|
8
|
-
false.must.be.false
|
9
|
-
|
10
|
-
(5 + 5).must.equal 10
|
11
|
-
|
12
|
-
[1,2,3].must.include(2)
|
13
|
-
|
14
|
-
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
-
|
16
|
-
false.must.be.false?
|
17
|
-
true.must.be.true?
|
18
|
-
|
19
|
-
(5 + 5).must == 10
|
20
|
-
|
21
|
-
Indefinite article `a` and `an` are suppored.
|
22
|
-
|
23
|
-
12.must.be.a.kind_of?(Integer)
|
24
|
-
|
25
|
-
12.must.be.an.instance_of?(Fixnum)
|
26
|
-
|
27
|
-
As is `not` for negation.
|
28
|
-
|
29
|
-
12.must.not.equal(20)
|
30
|
-
|
31
|
-
Or `must_not` can also be used.
|
32
|
-
|
33
|
-
12.must_not.equal(20)
|
34
|
-
|
35
|
-
We must also make sure such assertions can fail.
|
36
|
-
|
37
|
-
IncludeAssay.must.be.raised do
|
38
|
-
[1,2,3].must.include(4)
|
39
|
-
end
|
40
|
-
|
41
|
-
FalseAssay.must.be.raised do
|
42
|
-
true.must.be.false
|
43
|
-
end
|
44
|
-
|
45
|
-
EqualAssay.must.be.raised do
|
46
|
-
(5 + 5).must == 11
|
47
|
-
end
|
48
|
-
|
49
|
-
Matcher notation is also supported, if you have any matcher classes
|
50
|
-
to use. Assay classes can be converted to matchers, so we can use
|
51
|
-
one of those to try this out.
|
52
|
-
|
53
|
-
be_sixteen = EqualAssay[16.0]
|
54
|
-
|
55
|
-
16.must be_sixteen
|
56
|
-
|
57
|
-
15.must_not be_sixteen
|
58
|
-
|
data/spec/03_assert.rdoc
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
= Grammer
|
2
|
-
|
3
|
-
require 'fluidity/assert'
|
4
|
-
|
5
|
-
Now we have a fluent notation with which to make assertions.
|
6
|
-
|
7
|
-
true.assert.true
|
8
|
-
false.assert.false
|
9
|
-
|
10
|
-
(5 + 5).must.equal 10
|
11
|
-
|
12
|
-
[1,2,3].must.include(2)
|
13
|
-
|
14
|
-
We can also use the associated operator (Ruby's built-in query method name).
|
15
|
-
|
16
|
-
false.assert.false?
|
17
|
-
true.assert.true?
|
18
|
-
|
19
|
-
(5 + 5).assert == 10
|
20
|
-
|
21
|
-
(9 + 9).assert.not == 10
|
22
|
-
|
23
|
-
12.assert.kind_of?(Integer)
|
24
|
-
|
25
|
-
As is `not` for negation.
|
26
|
-
|
27
|
-
12.assert.not.equal(20)
|
28
|
-
|
29
|
-
Or `should_not` can also be used.
|
30
|
-
|
31
|
-
12.should_not.equal(20)
|
32
|
-
|
33
|
-
We must also make sure such assertions can fail. Since #assert is special
|
34
|
-
method to assay classes, we can use it as on these as part of our test
|
35
|
-
grmmer. So we use the raw `#assert!` method to handle the test.
|
36
|
-
|
37
|
-
RaiseAssay.assert!(IncludeAssay) do
|
38
|
-
[1,2,3].assert.include(4)
|
39
|
-
end
|
40
|
-
|
41
|
-
RaiseAssay.assert!(FalseAssay) do
|
42
|
-
true.assert.false
|
43
|
-
end
|
44
|
-
|
45
|
-
RaiseAssay.assert!(EqualityAssay) do
|
46
|
-
(5 + 5).assert == 11
|
47
|
-
end
|
48
|
-
|
49
|
-
Matcher notation is also supported, if you have any matcher classes
|
50
|
-
to use. Assay classes can be converted to matchers, so we can use
|
51
|
-
one of those to try this out.
|
52
|
-
|
53
|
-
is_sixteen = EqualityAssay[16.0]
|
54
|
-
|
55
|
-
16.assert is_sixteen
|
56
|
-
|
data/spec/04_other.rdoc
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
== Other Stuff
|
2
|
-
|
3
|
-
What if there is an assertion made for which no Assay class exists?
|
4
|
-
If the target object has a query method defined by the same name,
|
5
|
-
that is, one ending in a `?` mark, then that mehtod will be used
|
6
|
-
to test the assertion.
|
7
|
-
|
8
|
-
c = Class.new do
|
9
|
-
def initialize(truth)
|
10
|
-
@truth = truth
|
11
|
-
end
|
12
|
-
def yes?
|
13
|
-
@truth
|
14
|
-
end
|
15
|
-
def no?
|
16
|
-
!@truth
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
x = c.new(true)
|
21
|
-
|
22
|
-
x.should.be.yes
|
23
|
-
|
24
|
-
x.should_not.be.no
|