assay-minitest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ require 'assay-minitest'
@@ -0,0 +1,217 @@
1
+ = MiniTest Compatible Extensions
2
+
3
+ require 'assay/minitest'
4
+
5
+ class ::Object
6
+ include ::Assay::Extensions
7
+ end
8
+
9
+ == must_be
10
+
11
+ 1.must_be(:<, 2)
12
+ 1.must_be(:odd?)
13
+
14
+ expect ::ExecutionAssay do
15
+ 1.wont_be(:<, 2)
16
+ end
17
+
18
+ 1.wont_be(:>, 2)
19
+ 1.wont_be(:even?)
20
+
21
+ == must_equal
22
+
23
+ 1.must_equal(1)
24
+
25
+ expect ::EqualAssay do
26
+ 1.must_equal(2)
27
+ end
28
+
29
+ 1.wont_equal(2)
30
+
31
+ == TrueAssay
32
+
33
+ true.must_be_true
34
+
35
+ expect ::TrueAssay do
36
+ false.must_be_true
37
+ end
38
+
39
+ false.wont_be_true
40
+
41
+ == must_be_false
42
+
43
+ false.must_be_false
44
+
45
+ expect ::FalseAssay do
46
+ true.must_be_false
47
+ end
48
+
49
+ true.wont_be_false
50
+
51
+ == must_be_nil
52
+
53
+ nil.must_be_nil
54
+
55
+ expect ::NilAssay do
56
+ true.must_be_nil
57
+ end
58
+
59
+ false.wont_be_nil
60
+
61
+ == must_be_empty
62
+
63
+ [].must_be_empty
64
+
65
+ expect ::EmptyAssay do
66
+ [1].must_be_empty
67
+ end
68
+
69
+ [1].wont_be_empty
70
+
71
+ == must_include
72
+
73
+ [1].must_include(1)
74
+
75
+ expect ::IncludeAssay do
76
+ [1].must_include(2)
77
+ end
78
+
79
+ [1].wont_include(2)
80
+
81
+ == must_be_within_delta
82
+
83
+ 1.must_be_within_delta(2, 1.5)
84
+
85
+ expect ::WithinAssay do
86
+ 1.must_be_within_delta(2, 0.5)
87
+ end
88
+
89
+ 1.wont_be_within_delta(2, 0.5)
90
+
91
+ == must_match
92
+
93
+ "abc".must_match(/a/)
94
+
95
+ expect ::MatchAssay do
96
+ "abc".must_match(/x/)
97
+ end
98
+
99
+ "abc".wont_match(/g/)
100
+
101
+ == must_eql
102
+
103
+ 1.must_eql(1)
104
+
105
+ expect ::EqualityAssay do
106
+ 1.must_eql(1.0)
107
+ end
108
+
109
+ 1.wont_eql(1.0)
110
+
111
+ == must_be_same_as
112
+
113
+ :a.must_be_same_as(:a)
114
+
115
+ expect ::IdentityAssay do
116
+ "a".must_be_same_as("a")
117
+ end
118
+
119
+ :a.wont_be_same_as('a')
120
+
121
+ == must_be_instance_of
122
+
123
+ 1.must_be_instance_of(Fixnum)
124
+
125
+ expect ::InstanceAssay do
126
+ 1.must_be_instance_of(String)
127
+ end
128
+
129
+ 1.wont_be_instance_of(String)
130
+
131
+ == must_kind_of
132
+
133
+ 1.must_be_kind_of(Integer)
134
+
135
+ expect ::KindAssay do
136
+ 1.must_be_kind_of(String)
137
+ end
138
+
139
+ 1.wont_be_kind_of(String)
140
+
141
+ == must_raise
142
+
143
+ procedure = lambda{ raise ::ArgumentError }
144
+
145
+ procedure.must_raise(::ArgumentError)
146
+
147
+ expect ::RaiseAssay do
148
+ procedure.must_raise(::TypeError)
149
+ end
150
+
151
+ procedure.wont_raise(::TypeError)
152
+
153
+ == must_respond_to
154
+
155
+ "string".must_respond_to(:upcase)
156
+
157
+ expect ::RespondAssay do
158
+ "string".must_respond_to(:not_a_method)
159
+ end
160
+
161
+ "string".wont_respond_to(:not_a_method)
162
+
163
+ == must_satisfy
164
+
165
+ 5.must_satisfy{ |x| x > 3 }
166
+
167
+ expect ::ExecutionAssay do
168
+ 5.must_satisfy{ |x| x < 3 }
169
+ end
170
+
171
+ 5.wont_satisfy{ |x| x < 3 }
172
+
173
+ == must_send
174
+
175
+ 5.must_send([:+, 1])
176
+
177
+ expect ::ExecutionAssay do
178
+ 5.must_send([:upcase])
179
+ end
180
+
181
+ 5.wont_send([:upcase])
182
+
183
+ == must_throw
184
+
185
+ procedure = lambda{ throw :foo }
186
+
187
+ procedure.must_throw(:foo)
188
+
189
+ expect ::ThrowAssay do
190
+ procedure.must_throw(:bar)
191
+ end
192
+
193
+ procedure.wont_throw(:bar)
194
+
195
+ == must_output
196
+
197
+ procedure = lambda{ puts "fun!" }
198
+
199
+ procedure.must_output('fun!')
200
+
201
+ expect ::OutputAssay do
202
+ procedure.must_output('not!')
203
+ end
204
+
205
+ == must_be_like
206
+
207
+ The `#must_be_like` method is not a MiniText expectation, but we have thrown it
208
+ in for gooe measure.
209
+
210
+ /a/.must_be_like('a')
211
+
212
+ expect ::LikeAssay do
213
+ 'a'.must_be_like(10)
214
+ end
215
+
216
+ 'a'.wont_be_like(10)
217
+
@@ -0,0 +1,250 @@
1
+ = Assertion Methods
2
+
3
+ require 'assay/minitest'
4
+
5
+ include ::Assay::Assertions
6
+
7
+ == assert
8
+
9
+ assert(true, "yep it is so")
10
+
11
+ expect ::Assertion do
12
+ assert(false, "yep it is so")
13
+ end
14
+
15
+ refute(false, "not on you life")
16
+
17
+ == assert_boolean
18
+
19
+ assert_boolean(true)
20
+ assert_boolean(false)
21
+
22
+ refute_boolean(nil)
23
+ refute_boolean(:foo)
24
+
25
+ == assert_equal
26
+
27
+ assert_equal(1,1)
28
+
29
+ expect ::EqualAssay do
30
+ assert_equal(1,2)
31
+ end
32
+
33
+ refute_equal(1,2)
34
+
35
+ == assert_true
36
+
37
+ assert_true(true)
38
+
39
+ expect ::TrueAssay do
40
+ assert_true(false)
41
+ end
42
+
43
+ refute_true(false)
44
+
45
+ == assert_false
46
+
47
+ assert_false(false)
48
+
49
+ expect ::FalseAssay do
50
+ assert_false(true)
51
+ end
52
+
53
+ refute_false(true)
54
+
55
+ == assert_nil
56
+
57
+ assert_nil(nil)
58
+
59
+ expect ::NilAssay do
60
+ assert_nil(true)
61
+ end
62
+
63
+ refute_nil(true)
64
+ refute_nil(false)
65
+
66
+ == assert_in_delta
67
+
68
+ assert_in_delta(1, 1.5, 0.5)
69
+
70
+ expect ::WithinAssay do
71
+ assert_in_delta(1, 2.5, 1)
72
+ end
73
+
74
+ refute_in_delta(1, 2.5, 1)
75
+
76
+ == assert_in_epsilon
77
+
78
+ assert_in_epsilon(1, 1.5, 2)
79
+
80
+ expect ::WithinAssay do
81
+ assert_in_epsilon(1, 2.5, 1)
82
+ end
83
+
84
+ refute_in_epsilon(1, 2.5, 1)
85
+
86
+ == assert_match
87
+
88
+ assert_match(/a/, "abc")
89
+
90
+ expect ::MatchAssay do
91
+ assert_match(/x/, "abc")
92
+ end
93
+
94
+ refute_match(/a/, "bcd")
95
+
96
+ == assert_no_match
97
+
98
+ assert_no_match(/a/, "bcd")
99
+
100
+ expect ::MatchAssay do
101
+ assert_no_match(/a/, "abc")
102
+ end
103
+
104
+ == assert_operator
105
+
106
+ assert_operator(3, :<, 4)
107
+
108
+ expect ::ExecutionAssay do
109
+ assert_operator(4, :<, 3)
110
+ end
111
+
112
+ refute_operator(4, :<, 3)
113
+
114
+ == assert_equivalent
115
+
116
+ assert_equivalent(1, 1)
117
+
118
+ expect ::EqualityAssay do
119
+ assert_equivalent(1, 1.0)
120
+ end
121
+
122
+ refute_equivalent(1, 1.0)
123
+
124
+ == assert_empty
125
+
126
+ assert_empty([])
127
+
128
+ expect ::EmptyAssay do
129
+ assert_empty([1,2,3])
130
+ end
131
+
132
+ refute_empty([1,2,3])
133
+
134
+ == assert_include
135
+
136
+ assert_includes([1,2,3], 1)
137
+
138
+ expect ::IncludeAssay do
139
+ assert_includes([1,2,3], 4)
140
+ end
141
+
142
+ refute_includes([1,2,3], 4)
143
+
144
+ == assert_same
145
+
146
+ assert_same(:a, :a)
147
+
148
+ expect ::IdentityAssay do
149
+ assert_same("a", "a")
150
+ end
151
+
152
+ refute_same(:a, :b)
153
+
154
+ == assert_instance_of
155
+
156
+ assert_instance_of(Fixnum, 1)
157
+
158
+ expect ::InstanceAssay do
159
+ assert_instance_of(String, 1)
160
+ end
161
+
162
+ refute_instance_of(String, 1)
163
+
164
+ == assert_kind_of
165
+
166
+ assert_kind_of(Integer, 1)
167
+
168
+ expect ::KindAssay do
169
+ assert_kind_of(String, 1)
170
+ end
171
+
172
+ refute_kind_of(String, 1)
173
+
174
+ == assert_raises
175
+
176
+ assert_raises(ArgumentError){ raise ArgumentError }
177
+
178
+ expect ::RaiseAssay do
179
+ assert_raises(ArgumentError){ raise TypeError }
180
+ end
181
+
182
+ refute_raises(ArgumentError){ raise TypeError }
183
+
184
+ == assert_nothing_raised
185
+
186
+ assert_nothing_raised{ 'good' }
187
+
188
+ expect ::RescueAssay do
189
+ assert_nothing_raised{ raise }
190
+ end
191
+
192
+ refute_nothing_raised{ raise }
193
+
194
+ == assert_respond_to
195
+
196
+ assert_respond_to("string", :upcase)
197
+
198
+ expect ::RespondAssay do
199
+ assert_respond_to("string", :not_a_method)
200
+ end
201
+
202
+ refute_respond_to("string", :not_a_method)
203
+
204
+ == assert_block
205
+
206
+ assert_block{ :ok }
207
+
208
+ expect ::ExecutionAssay do
209
+ assert_block{ raise }
210
+ end
211
+
212
+ == assert_throws
213
+
214
+ assert_throws(:foo){ throw :foo }
215
+
216
+ expect ::ThrowAssay do
217
+ assert_throws(:foo){ throw :bar }
218
+ end
219
+
220
+ refute_throws(:foo){ throw :bar }
221
+
222
+ == assert_predicate
223
+
224
+ assert_predicate(10, :even?)
225
+
226
+ refute_predicate(10, :odd?)
227
+
228
+ == assert_output
229
+
230
+ assert_output('this'){ puts 'this' }
231
+
232
+ refute_output('this'){ puts 'that' }
233
+
234
+ == assert_silent
235
+
236
+ assert_silent{ nil }
237
+
238
+ refute_silent{ puts 'that' }
239
+
240
+ == assert_alike
241
+
242
+ assert_alike(1,1)
243
+ assert_alike(1,1.0)
244
+
245
+ expect ::LikeAssay do
246
+ assert_alike(1,"1")
247
+ end
248
+
249
+ refute_alike(1,"1")
250
+