spicycode-micronaut 0.0.7 → 0.0.9
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.
- data/Rakefile +1 -1
- data/examples/lib/micronaut/{behaviour_group_example.rb → behaviour_example.rb} +15 -13
- data/examples/lib/micronaut/configuration_example.rb +4 -4
- data/examples/lib/micronaut/example_example.rb +46 -0
- data/examples/lib/micronaut/expectations/extensions/object_example.rb +63 -76
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +4 -3
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +2 -2
- data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +8 -29
- data/examples/lib/micronaut/matchers/be_close_example.rb +48 -38
- data/examples/lib/micronaut/matchers/be_example.rb +287 -246
- data/examples/lib/micronaut/matchers/change_example.rb +306 -275
- data/examples/lib/micronaut/matchers/description_generation_example.rb +168 -160
- data/examples/lib/micronaut/matchers/eql_example.rb +30 -24
- data/examples/lib/micronaut/matchers/equal_example.rb +31 -25
- data/examples/lib/micronaut/matchers/handler_example.rb +36 -29
- data/examples/lib/micronaut/matchers/has_example.rb +57 -49
- data/examples/lib/micronaut/matchers/include_example.rb +89 -74
- data/examples/lib/micronaut/matchers/match_example.rb +33 -29
- data/examples/lib/micronaut/world_example.rb +4 -4
- data/lib/micronaut/{behaviour_group.rb → behaviour.rb} +8 -7
- data/lib/micronaut/configuration.rb +1 -1
- data/lib/micronaut/example.rb +5 -1
- data/lib/micronaut/formatters/base_formatter.rb +6 -6
- data/lib/micronaut/formatters/base_text_formatter.rb +8 -13
- data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
- data/lib/micronaut/formatters/progress_formatter.rb +1 -0
- data/lib/micronaut/formatters.rb +1 -0
- data/lib/micronaut/kernel_extensions.rb +1 -1
- data/lib/micronaut/runner.rb +1 -4
- data/lib/micronaut/runner_options.rb +11 -4
- data/lib/micronaut.rb +2 -2
- metadata +7 -4
@@ -1,257 +1,298 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe
|
4
|
-
it "should pass when actual returns true for :predicate?" do
|
5
|
-
actual = stub("actual", :happy? => true)
|
6
|
-
actual.should be_happy
|
7
|
-
end
|
3
|
+
describe Micronaut::Matchers do
|
8
4
|
|
9
|
-
|
10
|
-
actual = stub("actual", :exists? => true, :exist? => true)
|
11
|
-
actual.should be_exist
|
12
|
-
end
|
5
|
+
describe "should be_predicate" do
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
lambda {
|
7
|
+
it "should pass when actual returns true for :predicate?" do
|
8
|
+
actual = stub("actual", :happy? => true)
|
17
9
|
actual.should be_happy
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
actual
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should pass when actual returns true for :predicates? (present tense)" do
|
13
|
+
actual = stub("actual", :exists? => true, :exist? => true)
|
14
|
+
actual.should be_exist
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail when actual returns false for :predicate?" do
|
18
|
+
actual = stub("actual", :happy? => false)
|
19
|
+
lambda do
|
20
|
+
actual.should be_happy
|
21
|
+
end.should fail_with("expected happy? to return true, got false")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should fail when actual does not respond to :predicate?" do
|
25
|
+
lambda do
|
26
|
+
Object.new.should be_happy
|
27
|
+
end.should raise_error(NameError, /happy\?/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should fail on error other than NameError" do
|
31
|
+
actual = stub("actual")
|
32
|
+
actual.expects(:foo?).raises("aaaah")
|
33
|
+
lambda do
|
34
|
+
actual.should be_foo
|
35
|
+
end.should raise_error(/aaaah/)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should fail on error other than NameError (with the present tense predicate)" do
|
39
|
+
actual = Object.new
|
40
|
+
actual.expects(:foos?).raises("aaaah")
|
41
|
+
lambda do
|
42
|
+
actual.should be_foo
|
43
|
+
end.should raise_error(/aaaah/)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "should_not be_predicate" do
|
49
|
+
|
50
|
+
it "should pass when actual returns false for :sym?" do
|
51
|
+
actual = stub("actual", :happy? => false)
|
53
52
|
actual.should_not be_happy
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
actual
|
74
|
-
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should fail when actual returns true for :sym?" do
|
56
|
+
actual = stub("actual", :happy? => true)
|
57
|
+
lambda do
|
58
|
+
actual.should_not be_happy
|
59
|
+
end.should fail_with("expected happy? to return false, got true")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should fail when actual does not respond to :sym?" do
|
63
|
+
lambda do
|
64
|
+
Object.new.should_not be_happy
|
65
|
+
end.should raise_error(NameError)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "should be_predicate(*args)" do
|
71
|
+
|
72
|
+
it "should pass when actual returns true for :predicate?(*args)" do
|
73
|
+
actual = mock("actual")
|
74
|
+
actual.expects(:older_than?).with(3).returns(true)
|
75
75
|
actual.should be_older_than(3)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should fail when actual returns false for :predicate?(*args)" do
|
79
|
+
actual = mock("actual")
|
80
|
+
actual.expects(:older_than?).with(3).returns(false)
|
81
|
+
lambda do
|
82
|
+
actual.should be_older_than(3)
|
83
|
+
end.should fail_with("expected older_than?(3) to return true, got false")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should fail when actual does not respond to :predicate?" do
|
87
|
+
lambda do
|
88
|
+
Object.new.should be_older_than(3)
|
89
|
+
end.should raise_error(NameError)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "should_not be_predicate(*args)" do
|
95
|
+
|
96
|
+
it "should pass when actual returns false for :predicate?(*args)" do
|
97
|
+
actual = mock("actual")
|
98
|
+
actual.expects(:older_than?).with(3).returns(false)
|
97
99
|
actual.should_not be_older_than(3)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
describe "
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should fail when actual returns true for :predicate?(*args)" do
|
103
|
+
actual = mock("actual")
|
104
|
+
actual.expects(:older_than?).with(3).returns(true)
|
105
|
+
lambda do
|
106
|
+
actual.should_not be_older_than(3)
|
107
|
+
end.should fail_with("expected older_than?(3) to return false, got true")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should fail when actual does not respond to :predicate?" do
|
111
|
+
lambda do
|
112
|
+
Object.new.should_not be_older_than(3)
|
113
|
+
end.should raise_error(NameError)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "should be_true" do
|
119
|
+
|
120
|
+
it "should pass when actual equal(true)" do
|
121
|
+
true.should be_true
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should fail when actual equal(false)" do
|
125
|
+
lambda do
|
126
|
+
false.should be_true
|
127
|
+
end.should fail_with("expected true, got false")
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "should be_false" do
|
133
|
+
|
134
|
+
it "should pass when actual equal(false)" do
|
135
|
+
false.should be_false
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should fail when actual equal(true)" do
|
139
|
+
lambda do
|
140
|
+
true.should be_false
|
141
|
+
end.should fail_with("expected false, got true")
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "should be_nil" do
|
147
|
+
|
148
|
+
it "should pass when actual is nil" do
|
149
|
+
nil.should be_nil
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should fail when actual is not nil" do
|
153
|
+
lambda do
|
154
|
+
:not_nil.should be_nil
|
155
|
+
end.should fail_with("expected nil? to return true, got false")
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "should_not be_nil" do
|
161
|
+
|
162
|
+
it "should pass when actual is not nil" do
|
163
|
+
:not_nil.should_not be_nil
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should fail when actual is nil" do
|
167
|
+
lambda do
|
168
|
+
nil.should_not be_nil
|
169
|
+
end.should fail_with("expected nil? to return false, got true")
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "should be <" do
|
175
|
+
|
176
|
+
it "should pass when < operator returns true" do
|
177
|
+
3.should be < 4
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should fail when < operator returns false" do
|
181
|
+
lambda { 3.should be < 3 }.should fail_with("expected < 3, got 3")
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "should be <=" do
|
187
|
+
|
188
|
+
it "should pass when <= operator returns true" do
|
189
|
+
3.should be <= 4
|
190
|
+
4.should be <= 4
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should fail when <= operator returns false" do
|
194
|
+
lambda { 3.should be <= 2 }.should fail_with("expected <= 2, got 3")
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "should be >=" do
|
200
|
+
|
201
|
+
it "should pass when >= operator returns true" do
|
202
|
+
4.should be >= 4
|
203
|
+
5.should be >= 4
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should fail when >= operator returns false" do
|
207
|
+
lambda { 3.should be >= 4 }.should fail_with("expected >= 4, got 3")
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "should be >" do
|
213
|
+
|
214
|
+
it "should pass when > operator returns true" do
|
215
|
+
5.should be > 4
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should fail when > operator returns false" do
|
219
|
+
lambda { 3.should be > 4 }.should fail_with("expected > 4, got 3")
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "should be ==" do
|
225
|
+
|
226
|
+
it "should pass when == operator returns true" do
|
227
|
+
5.should be == 5
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should fail when == operator returns false" do
|
231
|
+
lambda { 3.should be == 4 }.should fail_with("expected == 4, got 3")
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "should be ===" do
|
237
|
+
|
238
|
+
it "should pass when === operator returns true" do
|
239
|
+
Hash.should be === Hash.new
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should fail when === operator returns false" do
|
243
|
+
lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === not a hash, got Hash])
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "should_not with operators" do
|
249
|
+
|
250
|
+
it "should coach user to stop using operators with should_not" do
|
251
|
+
lambda do
|
252
|
+
5.should_not be < 6
|
253
|
+
end.should raise_error(/not only FAILED,\nit reads really poorly./m)
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
describe "should be" do
|
259
|
+
|
260
|
+
it "should pass if actual is true or a set value" do
|
261
|
+
true.should be
|
262
|
+
1.should be
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should fail if actual is false" do
|
266
|
+
lambda {false.should be}.should fail_with("expected true, got false")
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should fail if actual is nil" do
|
270
|
+
lambda {nil.should be}.should fail_with("expected true, got nil")
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
describe "should be(value)" do
|
276
|
+
|
277
|
+
it "should pass if actual.equal?(value)" do
|
278
|
+
5.should be(5)
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should fail if !actual.equal?(value)" do
|
282
|
+
lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "'should be' with operator" do
|
288
|
+
|
289
|
+
it "should include 'be' in the description" do
|
290
|
+
(be > 6).description.should =~ /be > 6/
|
291
|
+
(be >= 6).description.should =~ /be >= 6/
|
292
|
+
(be <= 6).description.should =~ /be <= 6/
|
293
|
+
(be < 6).description.should =~ /be < 6/
|
294
|
+
end
|
295
|
+
|
153
296
|
end
|
154
|
-
end
|
155
297
|
|
156
|
-
describe "should be <" do
|
157
|
-
it "should pass when < operator returns true" do
|
158
|
-
3.should be < 4
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should fail when < operator returns false" do
|
162
|
-
lambda { 3.should be < 3 }.should fail_with("expected < 3, got 3")
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "should be <=" do
|
167
|
-
it "should pass when <= operator returns true" do
|
168
|
-
3.should be <= 4
|
169
|
-
4.should be <= 4
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should fail when <= operator returns false" do
|
173
|
-
lambda { 3.should be <= 2 }.should fail_with("expected <= 2, got 3")
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "should be >=" do
|
178
|
-
it "should pass when >= operator returns true" do
|
179
|
-
4.should be >= 4
|
180
|
-
5.should be >= 4
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should fail when >= operator returns false" do
|
184
|
-
lambda { 3.should be >= 4 }.should fail_with("expected >= 4, got 3")
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "should be >" do
|
189
|
-
it "should pass when > operator returns true" do
|
190
|
-
5.should be > 4
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should fail when > operator returns false" do
|
194
|
-
lambda { 3.should be > 4 }.should fail_with("expected > 4, got 3")
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
describe "should be ==" do
|
199
|
-
it "should pass when == operator returns true" do
|
200
|
-
5.should be == 5
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should fail when == operator returns false" do
|
204
|
-
lambda { 3.should be == 4 }.should fail_with("expected == 4, got 3")
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "should be ===" do
|
209
|
-
it "should pass when === operator returns true" do
|
210
|
-
Hash.should be === Hash.new
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should fail when === operator returns false" do
|
214
|
-
lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === not a hash, got Hash])
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe "should_not with operators" do
|
219
|
-
it "should coach user to stop using operators with should_not" do
|
220
|
-
lambda {
|
221
|
-
5.should_not be < 6
|
222
|
-
}.should raise_error(/not only FAILED,\nit reads really poorly./m)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "should be" do
|
227
|
-
it "should pass if actual is true or a set value" do
|
228
|
-
true.should be
|
229
|
-
1.should be
|
230
|
-
end
|
231
|
-
|
232
|
-
it "should fail if actual is false" do
|
233
|
-
lambda {false.should be}.should fail_with("expected true, got false")
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should fail if actual is nil" do
|
237
|
-
lambda {nil.should be}.should fail_with("expected true, got nil")
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "should be(value)" do
|
242
|
-
it "should pass if actual.equal?(value)" do
|
243
|
-
5.should be(5)
|
244
|
-
end
|
245
|
-
it "should fail if !actual.equal?(value)" do
|
246
|
-
lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "'should be' with operator" do
|
251
|
-
it "should include 'be' in the description" do
|
252
|
-
(be > 6).description.should =~ /be > 6/
|
253
|
-
(be >= 6).description.should =~ /be >= 6/
|
254
|
-
(be <= 6).description.should =~ /be <= 6/
|
255
|
-
(be < 6).description.should =~ /be < 6/
|
256
|
-
end
|
257
298
|
end
|