assay-testunit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby ADDED
@@ -0,0 +1,52 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Thomas Sawyer
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer
9
+ year: '2012'
10
+ license: BSD-2-Clause
11
+ replacements: []
12
+ alternatives: []
13
+ requirements:
14
+ - name: assay
15
+ - name: detroit
16
+ groups:
17
+ - build
18
+ development: true
19
+ - name: qed
20
+ groups:
21
+ - test
22
+ development: true
23
+ dependencies: []
24
+ conflicts: []
25
+ repositories:
26
+ - uri: git@github.com:rubyworks/assay-testunit.git
27
+ scm: git
28
+ name: upstream
29
+ resources:
30
+ home: http://rubyworks.github.com/assay-testunit
31
+ docs: http://rubydoc.info/gems/assay-testunit
32
+ code: http://github.com/rubyworks/assay-testunit
33
+ mail: http://groups.google.com/groups/rubyworks-mailinglist
34
+ extra: {}
35
+ load_path:
36
+ - lib
37
+ revision: 0
38
+ created: '2012-01-18'
39
+ summary: TestUnit on Assay
40
+ title: Assay TestUnit
41
+ version: 0.1.0
42
+ name: assay-testunit
43
+ description: ! 'Assay TestUnit defines a set of TestUnit-compatible assertion methods
44
+ which
45
+
46
+ depend on Assay''s assertion classes. This allows developers to change
47
+
48
+ test frameworks without having to change a slew of previously
49
+
50
+ defined assertions.'
51
+ organization: Rubyworks
52
+ date: '2012-01-25'
@@ -0,0 +1,7 @@
1
+ --title "Assay TestUnit"
2
+ --readme README.rdoc
3
+ --protected
4
+ --private
5
+ lib
6
+ -
7
+ [A-Z]*.*
@@ -0,0 +1,34 @@
1
+ = COPYRIGHT
2
+
3
+ == NOTICES
4
+
5
+ === Assay TestUnit
6
+
7
+ Copyright:: (c) 2012 Rubyworks
8
+ License:: BSD-2-Clause
9
+ Website:: http://rubyworks.github.com/assay-testunit
10
+
11
+ == LICENSES
12
+
13
+ === BSD-2-Clause License
14
+
15
+ Redistribution and use in source and binary forms, with or without
16
+ modification, are permitted provided that the following conditions are met:
17
+
18
+ 1. Redistributions of source code must retain the above copyright notice,
19
+ this list of conditions and the following disclaimer.
20
+
21
+ 2. Redistributions in binary form must reproduce the above copyright
22
+ notice, this list of conditions and the following disclaimer in the
23
+ documentation and/or other materials provided with the distribution.
24
+
25
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
26
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
27
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
32
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
34
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,267 @@
1
+ # Assertion Methods
2
+
3
+ To use the assertion methods, first require the library.
4
+
5
+ require 'assay/testunit'
6
+
7
+ Then include them into your test scope.
8
+
9
+ include ::Assay::Assertions
10
+
11
+ ## assert_equal
12
+
13
+ assert_equal(1,1)
14
+
15
+ expect ::EqualAssay do
16
+ assert_equal(1,2)
17
+ end
18
+
19
+ assert_not_equal(1,2)
20
+
21
+ ## assert_true
22
+
23
+ assert_true(true)
24
+
25
+ expect ::TrueAssay do
26
+ assert_true(false)
27
+ end
28
+
29
+ assert_not_true(false)
30
+ assert_not_true(nil)
31
+
32
+ ## assert_false
33
+
34
+ assert_false(false)
35
+
36
+ expect ::FalseAssay do
37
+ assert_false(true)
38
+ end
39
+
40
+ assert_not_false(true)
41
+ assert_not_false(nil)
42
+
43
+ ## assert_nil
44
+
45
+ assert_nil(nil)
46
+
47
+ expect ::NilAssay do
48
+ assert_nil(true)
49
+ end
50
+
51
+ assert_not_nil(true)
52
+ assert_not_nil(false)
53
+
54
+ ## assert_in_delta
55
+
56
+ assert_in_delta(1, 1.5, 2)
57
+
58
+ expect ::WithinAssay do
59
+ assert_in_delta(1, 2.5, 1)
60
+ end
61
+
62
+ assert_not_in_delta(1, 2, 0.5)
63
+
64
+ ## assert_in_epsilon
65
+
66
+ assert_in_epsilon(1, 1.5, 2)
67
+ assert_in_epsilon(0, 1.5, 2)
68
+
69
+ expect ::WithinAssay do
70
+ assert_in_epsilon(1, 2.5, 1)
71
+ end
72
+
73
+ assert_not_in_epsilon(1, 2.5, 1)
74
+ assert_not_in_epsilon(0, 2.5, 1)
75
+
76
+ ## assert_match
77
+
78
+ assert_match(/a/, "abc")
79
+
80
+ expect ::MatchAssay do
81
+ assert_match(/x/, "abc")
82
+ end
83
+
84
+ assert_not_match(/a/, "bcd")
85
+
86
+ ## assert_no_match
87
+
88
+ assert_no_match(/a/, "bcd")
89
+
90
+ expect ::NoMatchAssay do
91
+ assert_no_match(/a/, "abc")
92
+ end
93
+
94
+ ## assert_empty
95
+
96
+ assert_empty([])
97
+
98
+ expect ::EmptyAssay do
99
+ assert_empty([1,2,3])
100
+ end
101
+
102
+ assert_not_empty([1,2,3])
103
+
104
+ ## assert_include
105
+
106
+ assert_includes([1,2,3], 1)
107
+
108
+ expect ::IncludeAssay do
109
+ assert_includes([1,2,3], 4)
110
+ end
111
+
112
+ assert_not_includes([1,2,3], 4)
113
+
114
+ ## assert_same
115
+
116
+ assert_same(:a, :a)
117
+
118
+ expect ::IdentityAssay do
119
+ assert_same("a", "a")
120
+ end
121
+
122
+ assert_not_same(:a, :b)
123
+
124
+ ## assert_instance_of
125
+
126
+ assert_instance_of(Fixnum, 1)
127
+
128
+ expect ::InstanceAssay do
129
+ assert_instance_of(String, 1)
130
+ end
131
+
132
+ assert_not_instance_of(String, 1)
133
+
134
+ ## assert_kind_of
135
+
136
+ assert_kind_of(Integer, 1)
137
+
138
+ expect ::KindAssay do
139
+ assert_kind_of(String, 1)
140
+ end
141
+
142
+ assert_not_kind_of(String, 1)
143
+
144
+ ## assert_raise
145
+
146
+ assert_raise(ArgumentError){ raise ArgumentError }
147
+
148
+ expect ::RaiseAssay do
149
+ assert_raise(ArgumentError){ raise TypeError }
150
+ end
151
+
152
+ assert_not_raised(ArgumentError){ raise TypeError }
153
+
154
+ ## assert_raise_kind_of
155
+
156
+ assert_raise_kind_of(StandardError){ raise }
157
+
158
+ expect ::RescueAssay do
159
+ assert_raise_kind_of(ArgumentError){ raise TypeError }
160
+ end
161
+
162
+ assert_raise_kind_of(Exception){ raise }
163
+
164
+ ## assert_nothing_raised
165
+
166
+ assert_nothing_raised{ true }
167
+ assert_nothing_raised{ nil }
168
+
169
+ expect ::RescueAssay do
170
+ assert_nothing_raised{ raise }
171
+ end
172
+
173
+ ## assert_respond_to
174
+
175
+ assert_respond_to("string", :upcase)
176
+
177
+ expect ::RespondAssay do
178
+ assert_respond_to("string", :not_a_method)
179
+ end
180
+
181
+ assert_not_respond_to("string", :not_a_method)
182
+
183
+ ## assert_block
184
+
185
+ assert_block{ :ok }
186
+
187
+ expect ::ExecutionAssay do
188
+ assert_block{ raise }
189
+ end
190
+
191
+ ## assert_throw
192
+
193
+ assert_throw(:foo){ throw :foo }
194
+
195
+ expect ::ThrowAssay do
196
+ assert_throw(:foo){ throw :bar }
197
+ end
198
+
199
+ assert_not_thrown(:foo){ throw :bar }
200
+
201
+ ## assert_nothing_thrown
202
+
203
+ assert_nothing_thrown{ nil }
204
+
205
+ expect ::ThrowAssay do
206
+ assert_nothing_thrown{ throw :bar }
207
+ end
208
+
209
+ ## assert_compare
210
+
211
+ assert_compare(1, :<, 2)
212
+ assert_compare(2, :>, 1)
213
+ assert_compare(1, :<=, 1)
214
+ assert_compare(1, :>=, 1)
215
+ assert_compare(1, :<=, 2)
216
+ assert_compare(2, :>=, 1)
217
+ assert_compare(1, :==, 1)
218
+
219
+ expect ArgumentError do
220
+ assert_compare(1, :<=>, 1)
221
+ end
222
+
223
+ ## assert_operator
224
+
225
+ assert_operator([], :<<, 1)
226
+
227
+ ## assert_predicate
228
+
229
+ assert_predicate(10, :even?)
230
+
231
+ assert_not_predicate(10, :odd?)
232
+
233
+ ## assert_path_exist
234
+
235
+ assert_path_exist(__FILE__)
236
+
237
+ assert_path_not_exist(__FILE__ + '.foobar')
238
+
239
+ ## assert_boolean
240
+
241
+ assert_boolean(true)
242
+ assert_boolean(false)
243
+
244
+ assert_not_boolean(nil)
245
+
246
+ ## assert_alike
247
+
248
+ assert_alike(1,1)
249
+ assert_alike(1,1.0)
250
+
251
+ expect ::LikeAssay do
252
+ assert_alike(1,"1")
253
+ end
254
+
255
+ assert_not_alike(1,"1")
256
+
257
+ ## assert_equivalent
258
+
259
+ assert_equivalent(1, 1)
260
+
261
+ expect ::EqualityAssay do
262
+ assert_equivalent(1, 1.0)
263
+ end
264
+
265
+ assert_not_equivalent(1, 1.0)
266
+
267
+
@@ -0,0 +1,10 @@
1
+ = HISTORY
2
+
3
+ == 0.1.0 | 2012-01-25
4
+
5
+ This is the initial release of Assay TestUnit.
6
+
7
+ Changes:
8
+
9
+ * Happy Birthday!
10
+
@@ -0,0 +1,70 @@
1
+ = Assay TestUnit
2
+
3
+ {Homepage}[http://rubyworks.github.com/assay-testunit] /
4
+ {Report Issue}[http://github.com/rubyworks/assay-testunit/issues] /
5
+ {Source Code}[http://github.com/rubyworks/assay-testunit] /
6
+ {Mailing List}[http://groups.google.com/group/rubyworks-mailinglist]
7
+
8
+
9
+ == DESCRIPTION
10
+
11
+ Assay TestUnit is a compatibility layer for using TestUnit's assertion
12
+ notation with the {Assay}[http://rubyworks.github.com/assay]
13
+ assertions framework.
14
+
15
+ Assay TestUnit defines a set of TestUnit-compatible assertion methods
16
+ which depend on Assay's assertion classes. This allows developers to
17
+ change test frameworks without having to change a slew of previously
18
+ defined assertions calls.
19
+
20
+ Assay defines assertions in the same way that Ruby defines exceptions.
21
+ An assertion is nothing more that an extended Exception subclass.
22
+ Assay provides a complete set of these assertion classes for all
23
+ common assertion needs. See {Assay}[http://rubyworks.github.com/assay]
24
+ project for more information on this library.
25
+
26
+
27
+ == SYNOPSIS
28
+
29
+ Simply require the `assay/testunit` script, and include the `Assay::Assertions`
30
+ mixin module into your test scope, where your test framework requires it (which
31
+ may be as simple as the toplevel namespace).
32
+
33
+ require 'assay/testunit'
34
+
35
+ include Assay::Assertions
36
+
37
+ Now assertions can be made just as if you were using TestUnit.
38
+
39
+ assert_equal(10, 5+5)
40
+
41
+ assert_kind_of(Integer, 10)
42
+
43
+
44
+ == LIMITATIONS
45
+
46
+ Compatibility is not 100%, though it is very close. Compatibility will improve
47
+ with future releases. Please feel _obligated_ to submit a patch if you need a
48
+ missing a feature ;)
49
+
50
+ Assay TestUnit is also a Ruby 1.9+ only library.
51
+
52
+
53
+ == INSTALLATION
54
+
55
+ To install with RubyGems simply open a console and type:
56
+
57
+ $ gem install assay-testunit
58
+
59
+ Site installation with the tarball can be done with Ruby Setup
60
+ (gem install setup). See http://rubyworks.github.com/setup.
61
+
62
+
63
+ == COPYRIGHTS
64
+
65
+ Copyright (c) 2012 Rubyworks
66
+
67
+ This program is distributed under the terms of the *BSD-2-Clause* license.
68
+
69
+ See COPYING.rdoc file for details.
70
+
@@ -0,0 +1,10 @@
1
+ require 'assay'
2
+ require 'assay-testunit/assertions'
3
+
4
+ # This module holds all assertion methods, which can be mixed into
5
+ # one's testing scope (e.g. World).
6
+ #
7
+ module Assay::Assertions
8
+ include Assay::TestUnit::Assertions
9
+ end
10
+
@@ -0,0 +1,52 @@
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Thomas Sawyer
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer
9
+ year: '2012'
10
+ license: BSD-2-Clause
11
+ replacements: []
12
+ alternatives: []
13
+ requirements:
14
+ - name: assay
15
+ - name: detroit
16
+ groups:
17
+ - build
18
+ development: true
19
+ - name: qed
20
+ groups:
21
+ - test
22
+ development: true
23
+ dependencies: []
24
+ conflicts: []
25
+ repositories:
26
+ - uri: git@github.com:rubyworks/assay-testunit.git
27
+ scm: git
28
+ name: upstream
29
+ resources:
30
+ home: http://rubyworks.github.com/assay-testunit
31
+ docs: http://rubydoc.info/gems/assay-testunit
32
+ code: http://github.com/rubyworks/assay-testunit
33
+ mail: http://groups.google.com/groups/rubyworks-mailinglist
34
+ extra: {}
35
+ load_path:
36
+ - lib
37
+ revision: 0
38
+ created: '2012-01-18'
39
+ summary: TestUnit on Assay
40
+ title: Assay TestUnit
41
+ version: 0.1.0
42
+ name: assay-testunit
43
+ description: ! 'Assay TestUnit defines a set of TestUnit-compatible assertion methods
44
+ which
45
+
46
+ depend on Assay''s assertion classes. This allows developers to change
47
+
48
+ test frameworks without having to change a slew of previously
49
+
50
+ defined assertions.'
51
+ organization: Rubyworks
52
+ date: '2012-01-25'
@@ -0,0 +1,494 @@
1
+ module Assay; end
2
+ module Assay::TestUnit
3
+
4
+ # This module holds the Test::Unit assertion methods for Test::Unit
5
+ # compatibility.
6
+ #
7
+ # While it does not provide 100% of Test::Unit assertions at the moment,
8
+ # compatibility will improved with upcoming releases.
9
+ #
10
+ # @see http://test-unit.rubyforge.org/test-unit/en/
11
+ #
12
+ # @todo Should we adjust error message to be like Test::Units ?
13
+ #
14
+ module Assertions
15
+
16
+ #
17
+ #def assert_alias_method(object, alias_name, original_name, message = nil)
18
+ #end
19
+
20
+ #
21
+ # Passes if actual is like expected, where `like` means satisfyin any one
22
+ # of `#===`, `#==`, `#eql?` or `#equal?` calls.
23
+ #
24
+ # This is not strictly a Test::Unit assertion but is added here to cover
25
+ # all of Assay's availabe assertion classes.
26
+ #
27
+ def assert_alike(exp, act, msg=nil)
28
+ LikeAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
29
+ end
30
+
31
+ #
32
+ # Passes if actual is NOT like expected, where `like` means satisfyin any
33
+ # one of `#===`, `#==`, `#eql?` or `#equal?` calls.
34
+ #
35
+ def assert_not_alike(exp, act, msg=nil)
36
+ LikeAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
37
+ end
38
+
39
+ #
40
+ #
41
+ #
42
+ def assert_block(message="assert_block failed.", &block)
43
+ ExecutionAssay.assert!(:message=>message, &block)
44
+ end
45
+
46
+ #
47
+ # Passes if `boolean` is either `true` or `false`.
48
+ #
49
+ def assert_boolean(boolean, message=nil)
50
+ BooleanAssay.assert!(boolean, :message=>message)
51
+ end
52
+
53
+ #
54
+ # Passes if `boolean` is not either `true` or `false`.
55
+ #
56
+ def assert_not_boolean(boolean, message=nil)
57
+ BooleanAssay.refute!(boolean, :message=>message)
58
+ end
59
+
60
+ # Passes if `object` satisify compaision by `operator`.
61
+ #
62
+ def assert_compare(receiver, operator, operand, message=nil)
63
+ case operator.to_sym
64
+ when :<
65
+ LessAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
66
+ when :<=
67
+ LessEqualAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
68
+ when :>
69
+ MoreAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
70
+ when :>=
71
+ MoreEqualAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
72
+ when :==
73
+ EqualAssay.assert!(operand, receiver, :message=>message, :backtrace=>caller)
74
+ else
75
+ raise ArgumentError, "comparision operator must be one of <, <=, >, >= or '=='"
76
+ end
77
+ end
78
+
79
+ #
80
+ #
81
+ #
82
+ #def assert_const_defined(object, constant_name, message=nil)
83
+ #end
84
+
85
+ #
86
+ #
87
+ #
88
+ #def assert_not_const_defined(object, constant_name, message=nil)
89
+ #end
90
+
91
+ # Passes if object is empty.
92
+ #
93
+ # assert_empty(object)
94
+ #
95
+ def assert_empty(exp, msg=nil)
96
+ EmptyAssay.assert!(exp, :message=>msg, :backtrace=>caller)
97
+ end
98
+
99
+ # Passes if object is not empty.
100
+ #
101
+ # refute_empty(object)
102
+ #
103
+ def assert_not_empty(exp, msg=nil)
104
+ EmptyAssay.refute!(exp, :message=>msg, :backtrace=>caller)
105
+ end
106
+
107
+ # Passes if expected == +actual.
108
+ #
109
+ # Note that the ordering of arguments is important,
110
+ # since a helpful error message is generated when this
111
+ # one fails that tells you the values of expected and actual.
112
+ #
113
+ # assert_equal 'MY STRING', 'my string'.upcase
114
+ #
115
+ def assert_equal(exp, act, msg=nil)
116
+ EqualAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
117
+ end
118
+
119
+ # Passes if expected != actual
120
+ #
121
+ # assert_not_equal 'some string', 5
122
+ #
123
+ def assert_not_equal(exp, act, msg=nil)
124
+ EqualAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
125
+ end
126
+
127
+ #
128
+ #def assert_fail_assertion(message = nil)
129
+ #end
130
+
131
+ #
132
+ # Passed if object is +false+.
133
+ #
134
+ # assert_false(false)
135
+ #
136
+ def assert_false(exp, msg=nil)
137
+ FalseAssay.assert!(exp, :message=>msg, :backtrace=>caller)
138
+ end
139
+
140
+ #
141
+ # Passed if object is not +false+.
142
+ #
143
+ # assert_not_false(false)
144
+ #
145
+ def assert_not_false(exp, msg=nil)
146
+ FalseAssay.refute!(exp, :message=>msg, :backtrace=>caller)
147
+ end
148
+
149
+ #
150
+ # Passes if expected and actual are equal within delta tolerance.
151
+ #
152
+ # assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
153
+ #
154
+ def assert_in_delta(exp, act, delta, msg=nil)
155
+ WithinAssay.assert!(act, exp, delta, :message=>msg, :backtrace=>caller)
156
+ end
157
+
158
+ #
159
+ # Passes if expected and actual are equal not within delta tolerance.
160
+ #
161
+ # assert_not_in_delta 0.05, (50000.0 / 10**6), 0.00001
162
+ #
163
+ def assert_not_in_delta(exp, act, delta, msg=nil)
164
+ WithinAssay.refute!(act, exp, delta, :message=>msg, :backtrace=>caller)
165
+ end
166
+
167
+ #
168
+ # Passes if `exp` and `act` are within `epsilon`.
169
+ #
170
+ def assert_in_epsilon(exp, act, epsilon=0.001, message=nil)
171
+ exp = exp.to_f
172
+ if exp.zero?
173
+ delta = epsilon.to_f ** 2
174
+ else
175
+ delta = exp * epsilon.to_f
176
+ end
177
+ WithinAssay.assert!(act, exp, delta, :message=>message, :backtrace=>caller)
178
+ end
179
+
180
+ #
181
+ # Passes if `exp` and `act` are NOT within `epsilon`.
182
+ #
183
+ def assert_not_in_epsilon(exp, act, epsilon=0.001, message=nil)
184
+ exp = exp.to_f
185
+ if exp.zero?
186
+ delta = epsilon.to_f ** 2
187
+ else
188
+ delta = exp * epsilon.to_f
189
+ end
190
+ WithinAssay.refute!(act, exp, delta, :message=>message, :backtrace=>caller)
191
+ end
192
+
193
+ #
194
+ # Passes if `collection` contains `member`.
195
+ #
196
+ def assert_includes(collection, member, message=nil)
197
+ IncludeAssay.assert!(collection, member, :message=>message, :backtrace=>caller)
198
+ end
199
+
200
+ #
201
+ # Passes if `collection` does not contain `member`.
202
+ #
203
+ def assert_not_includes(collection, member, message=nil)
204
+ IncludeAssay.refute!(collection, member, :message=>message, :backtrace=>caller)
205
+ end
206
+
207
+ #
208
+ # Passes if object is an instance of class.
209
+ #
210
+ # assert_instance_of(String, 'foo')
211
+ #
212
+ def assert_instance_of(cls, obj, msg=nil)
213
+ InstanceAssay.assert!(obj, cls, :message=>msg, :backtrace=>caller)
214
+ end
215
+
216
+ #
217
+ # Passes if object is not an instance of class.
218
+ #
219
+ # assert_not_instance_of(String, 500)
220
+ #
221
+ def assert_not_instance_of(cls, obj, msg=nil)
222
+ InstanceAssay.refute!(obj, cls, :message=>msg, :backtrace=>caller)
223
+ end
224
+
225
+ #
226
+ # Passes if object .kind_of? klass
227
+ #
228
+ # assert_kind_of(Object, 'foo')
229
+ #
230
+ def assert_kind_of(cls, obj, msg=nil)
231
+ KindAssay.assert!(obj, cls, :message=>msg, :backtrace=>caller)
232
+ end
233
+
234
+ #
235
+ # Passes if object .kind_of? klass
236
+ #
237
+ # assert_not_kind_of(Object, 'foo')
238
+ #
239
+ def assert_not_kind_of(cls, obj, msg=nil)
240
+ KindAssay.refute!(obj, cls, :message=>msg, :backtrace=>caller)
241
+ end
242
+
243
+ # Passes if object matches pattern using `#=~` method.
244
+ #
245
+ # assert_match(/\d+/, 'five, 6, seven')
246
+ #
247
+ def assert_match(pattern, string, msg=nil)
248
+ MatchAssay.assert!(string, pattern, :message=>msg, :backtrace=>caller)
249
+ end
250
+
251
+ # Passes if object does not match pattern using `#=~` method.
252
+ #
253
+ # assert_no_match(/two/, 'one 2 three')
254
+ #
255
+ def assert_not_match(pattern, string, msg=nil)
256
+ MatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)
257
+ end
258
+
259
+ # Passes if object has no match pattern using `#!~` method.
260
+ #
261
+ # assert_no_match(/two/, 'one 2 three')
262
+ #
263
+ def assert_no_match(pattern, string, msg=nil)
264
+ NoMatchAssay.assert!(string, pattern, :message=>msg, :backtrace=>caller)
265
+ end
266
+
267
+ ## Passes if object has a match pattern using `#!~` method.
268
+ ##
269
+ ## assert_not_no_match(/two/, 'one two three')
270
+ ##
271
+ #def assert_not_no_match(pattern, string, msg=nil)
272
+ # NoMatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)
273
+ #end
274
+
275
+ # Passed if object is +nil+.
276
+ #
277
+ # assert_nil(nil)
278
+ #
279
+ def assert_nil(exp, msg=nil)
280
+ NilAssay.assert!(exp, :message=>msg, :backtrace=>caller)
281
+ end
282
+
283
+ # Passed if object is not +nil+.
284
+ #
285
+ # assert_not_nil(true)
286
+ #
287
+ def assert_not_nil(exp, msg=nil)
288
+ NilAssay.refute!(exp, :message=>msg, :backtrace=>caller)
289
+ end
290
+
291
+ #
292
+ #
293
+ #
294
+ def assert_predicate(object, predicate, message = nil)
295
+ ExecutionAssay.assert!(:message=>message) do
296
+ object.__send__(predicate)
297
+ end
298
+ end
299
+
300
+ #
301
+ #
302
+ #
303
+ def assert_not_predicate(object, predicate, message = nil)
304
+ ExecutionAssay.refute!(:message=>message) do
305
+ object.__send__(predicate)
306
+ end
307
+ end
308
+
309
+ #
310
+ # Passes if +object+ respond_to? +methods+.
311
+ #
312
+ # assert_respond_to 'bugbear', :slice
313
+ #
314
+ def assert_respond_to(reciever, method, msg=nil)
315
+ RespondAssay.assert!(reciever, method, :message=>msg, :backtrace=>caller)
316
+ end
317
+ alias_method :assert_responds_to, :assert_respond_to
318
+
319
+ #
320
+ # Passes if +object+ does not respond_to? +methods+.
321
+ #
322
+ # assert_not_respond_to 'bugbear', :slice
323
+ #
324
+ def assert_not_respond_to(reciever, method, msg=nil)
325
+ RespondAssay.refute!(reciever, method, :message=>msg, :backtrace=>caller)
326
+ end
327
+
328
+ # Passes if +expected+ .eql? +actual+.
329
+ #
330
+ # Note that the ordering of arguments is important,
331
+ # since a helpful error message is generated when this
332
+ # one fails that tells you the values of expected and actual.
333
+ #
334
+ # assert_equivalent 'MY STRING', 'my string'.upcase
335
+ #
336
+ def assert_equivalent(exp, act, msg=nil)
337
+ EqualityAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
338
+ end
339
+
340
+ # Passes if +criterion+ is NOT equivalent to +actual+ as tested using `#eql?`.
341
+ #
342
+ # assert_not_equivalent 1, 1.0
343
+ #
344
+ def assert_not_equivalent(criterion, act, msg=nil)
345
+ EqualityAssay.refute!(act, criterion, :message=>msg, :backtrace=>caller)
346
+ end
347
+
348
+ #
349
+ #
350
+ # TODO: Is this supposed to be restricted in some way?
351
+ def assert_operator(receiver, operator, operand, message=nil)
352
+ ExecutionAssay.assert!(:message=>message, :backtrace=>caller) do
353
+ receiver.__send__(operator, operand)
354
+ end
355
+ end
356
+
357
+ #
358
+ #
359
+ #
360
+ def assert_path_exist(path, message=nil)
361
+ PathAssay.assert!(path, :message=>message, :backtrace=>caller)
362
+ end
363
+
364
+ #
365
+ #
366
+ #
367
+ def assert_path_not_exist(path, message=nil)
368
+ PathAssay.refute!(path, :message=>message, :backtrace=>caller)
369
+ end
370
+
371
+ #
372
+ # Passes if the block raises a given exception.
373
+ #
374
+ # assert_raise RuntimeError do
375
+ # raise 'Boom!!!'
376
+ # end
377
+ #
378
+ def assert_raise(exception, message=nil, &block)
379
+ RaiseAssay.assert!(exception, :message=>message, :backtrace=>caller, &block)
380
+ end
381
+
382
+ alias_method :assert_raises, :assert_raise
383
+
384
+ #
385
+ # Passes if the block *does not* raise a given exceptions.
386
+ #
387
+ # assert_not_raised IOError do
388
+ # raise 'Boom!!!'
389
+ # end
390
+ #
391
+ def assert_not_raised(exception, message=nil, &block) #:yeild:
392
+ RaiseAssay.refute!(exception, :message=>message, :backtrace=>caller, &block)
393
+ end
394
+
395
+ #
396
+ # Passes if the block yields successfully.
397
+ #
398
+ # assert_nothing_raised "Couldn't do the thing" do
399
+ # do_the_thing
400
+ # end
401
+ #
402
+ def assert_nothing_raised(message=nil, &block)
403
+ RescueAssay.refute!(Exception, :message=>message, :backtrace=>caller, &block)
404
+ end
405
+
406
+ #
407
+ # Passes if the block raises a given exception.
408
+ #
409
+ # assert_raise_kind_of RuntimeError do
410
+ # raise 'Boom!!!'
411
+ # end
412
+ #
413
+ def assert_raise_kind_of(exception_class, message=nil, &block)
414
+ RescueAssay.assert!(exception_class, :message=>message, :backtrace=>caller, &block)
415
+ end
416
+
417
+ #
418
+ #def assert_raise_message(*args, &block)
419
+ #end
420
+
421
+ #
422
+ # Passes if actual is the same exact object as expected.
423
+ #
424
+ # assert_same(object, object)
425
+ #
426
+ def assert_same(exp, act, msg=nil)
427
+ IdentityAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
428
+ end
429
+
430
+ #
431
+ # Passes if actual is not the same exact object as expected.
432
+ #
433
+ # assert_not_same(object, other)
434
+ #
435
+ def assert_not_same(exp, act, msg=nil)
436
+ IdentityAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
437
+ end
438
+
439
+ #
440
+ #
441
+ #
442
+ #def assert_send(send_array, message=nil)
443
+ #end
444
+
445
+ #
446
+ # Passes if the block throws `expected` object.
447
+ #
448
+ # assert_throw :done do
449
+ # throw :done
450
+ # end
451
+ #
452
+ def assert_throw(expected, msg=nil, &blk)
453
+ ThrowAssay.assert!(expected, :message=>msg, :backtrace=>caller, &blk)
454
+ end
455
+
456
+ alias_method :assert_throws, :assert_throw
457
+
458
+ #
459
+ # Passes if the block does not throws `expected` object.
460
+ #
461
+ # assert_not_thrown :done do
462
+ # throw :chimp
463
+ # end
464
+ #
465
+ def assert_not_thrown(expected, msg=nil, &blk)
466
+ ThrowAssay.refute!(expected, :message=>msg, :backtrace=>caller, &blk)
467
+ end
468
+
469
+ #
470
+ #
471
+ #
472
+ def assert_nothing_thrown(message=nil, &blk)
473
+ ThrowAssay.refute!(nil, :message=>message, &blk)
474
+ end
475
+
476
+ #
477
+ # Passed if object is +true+.
478
+ #
479
+ def assert_true(exp, msg=nil)
480
+ TrueAssay.assert!(exp, :message=>msg, :backtrace=>caller)
481
+ end
482
+
483
+ #
484
+ # Passed if object is not +true+.
485
+ #
486
+ # assert_not_true(false)
487
+ #
488
+ def assert_not_true(exp, msg=nil)
489
+ TrueAssay.refute!(exp, :message=>msg, :backtrace=>caller)
490
+ end
491
+
492
+ end
493
+
494
+ end
@@ -0,0 +1 @@
1
+ require 'assay-testunit'
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assay-testunit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Sawyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: assay
16
+ requirement: &12135040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12135040
25
+ - !ruby/object:Gem::Dependency
26
+ name: detroit
27
+ requirement: &12125400 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *12125400
36
+ - !ruby/object:Gem::Dependency
37
+ name: qed
38
+ requirement: &12115700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *12115700
47
+ description: ! 'Assay TestUnit defines a set of TestUnit-compatible assertion methods
48
+ which
49
+
50
+ depend on Assay''s assertion classes. This allows developers to change
51
+
52
+ test frameworks without having to change a slew of previously
53
+
54
+ defined assertions.'
55
+ email:
56
+ - transfire@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files:
60
+ - HISTORY.rdoc
61
+ - DEMOS.rdoc
62
+ - README.rdoc
63
+ - COPYING.rdoc
64
+ files:
65
+ - .ruby
66
+ - .yardopts
67
+ - lib/assay/testunit.rb
68
+ - lib/assay-testunit/assertions.rb
69
+ - lib/assay-testunit.rb
70
+ - lib/assay-testunit.yml
71
+ - HISTORY.rdoc
72
+ - DEMOS.rdoc
73
+ - README.rdoc
74
+ - COPYING.rdoc
75
+ homepage: http://rubyworks.github.com/assay-testunit
76
+ licenses:
77
+ - BSD-2-Clause
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.10
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: TestUnit on Assay
100
+ test_files: []