spicycode-micronaut 0.1.6.8 → 0.1.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/examples/example_helper.rb +3 -3
- data/examples/lib/micronaut/matchers/have_example.rb +261 -442
- data/examples/lib/micronaut/world_example.rb +7 -0
- data/examples/lib/micronaut_example.rb +1 -1
- data/lib/micronaut/formatters/base_formatter.rb +2 -2
- data/lib/micronaut/formatters/documentation_formatter.rb +3 -1
- data/lib/micronaut/world.rb +3 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -35,8 +35,8 @@ end
|
|
35
35
|
Micronaut.configure do |config|
|
36
36
|
config.mock_with :mocha
|
37
37
|
config.color_enabled = use_color?
|
38
|
-
config.formatter = :
|
39
|
-
config.profile_examples =
|
38
|
+
config.formatter = :documentation
|
39
|
+
config.profile_examples = false
|
40
40
|
config.filter_run :focused => true
|
41
41
|
config.autorun!
|
42
|
-
end
|
42
|
+
end
|
@@ -1,41 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# owner = Micronaut::Expectations::Helper::CollectionOwner.new
|
6
|
-
# (1..n).each do |n|
|
7
|
-
# owner.add_to_collection_with_length_method(n)
|
8
|
-
# owner.add_to_collection_with_size_method(n)
|
9
|
-
# end
|
10
|
-
# owner
|
11
|
-
# end
|
12
|
-
# before do
|
13
|
-
# unless defined?(ActiveSupport::Inflector)
|
14
|
-
# @active_support_was_not_defined
|
15
|
-
# module ActiveSupport
|
16
|
-
# class Inflector
|
17
|
-
# def self.pluralize(string)
|
18
|
-
# string.to_s + 's'
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
|
26
|
-
|
27
|
-
describe "should have(n).items" do
|
28
|
-
# include HaveMicronautHelper
|
29
|
-
|
30
|
-
def create_collection_owner_with(n)
|
31
|
-
owner = Micronaut::Expectations::Helper::CollectionOwner.new
|
32
|
-
(1..n).each do |n|
|
33
|
-
owner.add_to_collection_with_length_method(n)
|
34
|
-
owner.add_to_collection_with_size_method(n)
|
35
|
-
end
|
36
|
-
owner
|
37
|
-
end
|
38
|
-
|
3
|
+
describe Micronaut::Matchers, "have" do
|
4
|
+
|
39
5
|
before do
|
40
6
|
unless defined?(ActiveSupport::Inflector)
|
41
7
|
@active_support_was_not_defined
|
@@ -49,42 +15,6 @@ describe "should have(n).items" do
|
|
49
15
|
end
|
50
16
|
end
|
51
17
|
|
52
|
-
it "should pass if target has a collection of items with n members" do
|
53
|
-
owner = create_collection_owner_with(3)
|
54
|
-
owner.should have(3).items_in_collection_with_length_method
|
55
|
-
owner.should have(3).items_in_collection_with_size_method
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should convert :no to 0" do
|
59
|
-
owner = create_collection_owner_with(0)
|
60
|
-
owner.should have(:no).items_in_collection_with_length_method
|
61
|
-
owner.should have(:no).items_in_collection_with_size_method
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should fail if target has a collection of items with < n members" do
|
65
|
-
owner = create_collection_owner_with(3)
|
66
|
-
lambda {
|
67
|
-
owner.should have(4).items_in_collection_with_length_method
|
68
|
-
}.should fail_with("expected 4 items_in_collection_with_length_method, got 3")
|
69
|
-
lambda {
|
70
|
-
owner.should have(4).items_in_collection_with_size_method
|
71
|
-
}.should fail_with("expected 4 items_in_collection_with_size_method, got 3")
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should fail if target has a collection of items with > n members" do
|
75
|
-
owner = create_collection_owner_with(3)
|
76
|
-
lambda {
|
77
|
-
owner.should have(2).items_in_collection_with_length_method
|
78
|
-
}.should fail_with("expected 2 items_in_collection_with_length_method, got 3")
|
79
|
-
lambda {
|
80
|
-
owner.should have(2).items_in_collection_with_size_method
|
81
|
-
}.should fail_with("expected 2 items_in_collection_with_size_method, got 3")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
86
|
-
# include HaveMicronautHelper
|
87
|
-
|
88
18
|
def create_collection_owner_with(n)
|
89
19
|
owner = Micronaut::Expectations::Helper::CollectionOwner.new
|
90
20
|
(1..n).each do |n|
|
@@ -93,48 +23,61 @@ describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
|
93
23
|
end
|
94
24
|
owner
|
95
25
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
26
|
+
|
27
|
+
describe "should have(n).items" do
|
28
|
+
|
29
|
+
it "should pass if target has a collection of items with n members" do
|
30
|
+
owner = create_collection_owner_with(3)
|
31
|
+
owner.should have(3).items_in_collection_with_length_method
|
32
|
+
owner.should have(3).items_in_collection_with_size_method
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should convert :no to 0" do
|
36
|
+
owner = create_collection_owner_with(0)
|
37
|
+
owner.should have(:no).items_in_collection_with_length_method
|
38
|
+
owner.should have(:no).items_in_collection_with_size_method
|
107
39
|
end
|
108
|
-
end
|
109
40
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
41
|
+
it "should fail if target has a collection of items with < n members" do
|
42
|
+
owner = create_collection_owner_with(3)
|
43
|
+
lambda {
|
44
|
+
owner.should have(4).items_in_collection_with_length_method
|
45
|
+
}.should fail_with("expected 4 items_in_collection_with_length_method, got 3")
|
46
|
+
lambda {
|
47
|
+
owner.should have(4).items_in_collection_with_size_method
|
48
|
+
}.should fail_with("expected 4 items_in_collection_with_size_method, got 3")
|
49
|
+
end
|
114
50
|
|
115
|
-
|
116
|
-
|
117
|
-
|
51
|
+
it "should fail if target has a collection of items with > n members" do
|
52
|
+
owner = create_collection_owner_with(3)
|
53
|
+
lambda {
|
54
|
+
owner.should have(2).items_in_collection_with_length_method
|
55
|
+
}.should fail_with("expected 2 items_in_collection_with_length_method, got 3")
|
56
|
+
lambda {
|
57
|
+
owner.should have(2).items_in_collection_with_size_method
|
58
|
+
}.should fail_with("expected 2 items_in_collection_with_size_method, got 3")
|
118
59
|
end
|
119
60
|
end
|
120
|
-
end
|
121
61
|
|
122
|
-
describe 'should have(1).item when Inflector is defined' do
|
123
|
-
|
62
|
+
describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
63
|
+
|
64
|
+
it 'should pluralize the collection name' do
|
65
|
+
owner = create_collection_owner_with(1)
|
66
|
+
owner.should have(1).item
|
67
|
+
end
|
124
68
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
owner.add_to_collection_with_size_method(n)
|
69
|
+
after do
|
70
|
+
if @active_support_was_not_defined
|
71
|
+
Object.__send__ :remove_const, :ActiveSupport
|
72
|
+
end
|
130
73
|
end
|
131
|
-
owner
|
132
74
|
end
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
75
|
+
|
76
|
+
describe 'should have(1).item when Inflector is defined' do
|
77
|
+
|
78
|
+
before do
|
79
|
+
unless defined?(Inflector)
|
80
|
+
@inflector_was_not_defined
|
138
81
|
class Inflector
|
139
82
|
def self.pluralize(string)
|
140
83
|
string.to_s + 's'
|
@@ -142,209 +85,128 @@ describe 'should have(1).item when Inflector is defined' do
|
|
142
85
|
end
|
143
86
|
end
|
144
87
|
end
|
145
|
-
end
|
146
|
-
|
147
|
-
before do
|
148
|
-
unless defined?(Inflector)
|
149
|
-
@inflector_was_not_defined
|
150
|
-
class Inflector
|
151
|
-
def self.pluralize(string)
|
152
|
-
string.to_s + 's'
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
88
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
after do
|
164
|
-
if @inflector_was_not_defined
|
165
|
-
Object.__send__ :remove_const, :Inflector
|
89
|
+
it 'should pluralize the collection name' do
|
90
|
+
owner = create_collection_owner_with(1)
|
91
|
+
owner.should have(1).item
|
166
92
|
end
|
167
|
-
end
|
168
|
-
end
|
169
93
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
def items
|
174
|
-
Object.new
|
94
|
+
after do
|
95
|
+
if @inflector_was_not_defined
|
96
|
+
Object.__send__ :remove_const, :Inflector
|
175
97
|
end
|
176
|
-
end.new
|
177
|
-
lambda do
|
178
|
-
owner.should have(3).items
|
179
|
-
end.should raise_error("expected items to be a collection but it does not respond to #length or #size")
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
describe "should_not have(n).items" do
|
184
|
-
# include HaveMicronautHelper
|
185
|
-
|
186
|
-
def create_collection_owner_with(n)
|
187
|
-
owner = Micronaut::Expectations::Helper::CollectionOwner.new
|
188
|
-
(1..n).each do |n|
|
189
|
-
owner.add_to_collection_with_length_method(n)
|
190
|
-
owner.add_to_collection_with_size_method(n)
|
191
98
|
end
|
192
|
-
owner
|
193
99
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
def self.pluralize(string)
|
201
|
-
string.to_s + 's'
|
202
|
-
end
|
100
|
+
|
101
|
+
describe "should have(n).items where result responds to items but returns something other than a collection" do
|
102
|
+
it "should provide a meaningful error" do
|
103
|
+
owner = Class.new do
|
104
|
+
def items
|
105
|
+
Object.new
|
203
106
|
end
|
204
|
-
end
|
107
|
+
end.new
|
108
|
+
lambda do
|
109
|
+
owner.should have(3).items
|
110
|
+
end.should raise_error("expected items to be a collection but it does not respond to #length or #size")
|
205
111
|
end
|
206
112
|
end
|
207
|
-
|
208
|
-
it "should pass if target has a collection of items with < n members" do
|
209
|
-
owner = create_collection_owner_with(3)
|
210
|
-
owner.should_not have(4).items_in_collection_with_length_method
|
211
|
-
owner.should_not have(4).items_in_collection_with_size_method
|
212
|
-
end
|
213
|
-
|
214
|
-
it "should pass if target has a collection of items with > n members" do
|
215
|
-
owner = create_collection_owner_with(3)
|
216
|
-
owner.should_not have(2).items_in_collection_with_length_method
|
217
|
-
owner.should_not have(2).items_in_collection_with_size_method
|
218
|
-
end
|
219
113
|
|
220
|
-
|
221
|
-
owner = create_collection_owner_with(3)
|
222
|
-
lambda {
|
223
|
-
owner.should_not have(3).items_in_collection_with_length_method
|
224
|
-
}.should fail_with("expected target not to have 3 items_in_collection_with_length_method, got 3")
|
225
|
-
lambda {
|
226
|
-
owner.should_not have(3).items_in_collection_with_size_method
|
227
|
-
}.should fail_with("expected target not to have 3 items_in_collection_with_size_method, got 3")
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe "should have_exactly(n).items" do
|
232
|
-
# include HaveMicronautHelper
|
114
|
+
describe "should_not have(n).items" do
|
233
115
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
owner.
|
238
|
-
owner.add_to_collection_with_size_method(n)
|
116
|
+
it "should pass if target has a collection of items with < n members" do
|
117
|
+
owner = create_collection_owner_with(3)
|
118
|
+
owner.should_not have(4).items_in_collection_with_length_method
|
119
|
+
owner.should_not have(4).items_in_collection_with_size_method
|
239
120
|
end
|
240
|
-
owner
|
241
|
-
end
|
242
121
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
class Inflector
|
248
|
-
def self.pluralize(string)
|
249
|
-
string.to_s + 's'
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
122
|
+
it "should pass if target has a collection of items with > n members" do
|
123
|
+
owner = create_collection_owner_with(3)
|
124
|
+
owner.should_not have(2).items_in_collection_with_length_method
|
125
|
+
owner.should_not have(2).items_in_collection_with_size_method
|
253
126
|
end
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should pass if target has a collection of items with n members" do
|
257
|
-
owner = create_collection_owner_with(3)
|
258
|
-
owner.should have_exactly(3).items_in_collection_with_length_method
|
259
|
-
owner.should have_exactly(3).items_in_collection_with_size_method
|
260
|
-
end
|
261
127
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
128
|
+
it "should fail if target has a collection of items with n members" do
|
129
|
+
owner = create_collection_owner_with(3)
|
130
|
+
lambda {
|
131
|
+
owner.should_not have(3).items_in_collection_with_length_method
|
132
|
+
}.should fail_with("expected target not to have 3 items_in_collection_with_length_method, got 3")
|
133
|
+
lambda {
|
134
|
+
owner.should_not have(3).items_in_collection_with_size_method
|
135
|
+
}.should fail_with("expected target not to have 3 items_in_collection_with_size_method, got 3")
|
136
|
+
end
|
266
137
|
end
|
267
138
|
|
268
|
-
|
269
|
-
owner = create_collection_owner_with(3)
|
270
|
-
lambda {
|
271
|
-
owner.should have_exactly(4).items_in_collection_with_length_method
|
272
|
-
}.should fail_with("expected 4 items_in_collection_with_length_method, got 3")
|
273
|
-
lambda {
|
274
|
-
owner.should have_exactly(4).items_in_collection_with_size_method
|
275
|
-
}.should fail_with("expected 4 items_in_collection_with_size_method, got 3")
|
276
|
-
end
|
139
|
+
describe "should have_exactly(n).items" do
|
277
140
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
owner.should have_exactly(
|
282
|
-
|
283
|
-
lambda {
|
284
|
-
owner.should have_exactly(2).items_in_collection_with_size_method
|
285
|
-
}.should fail_with("expected 2 items_in_collection_with_size_method, got 3")
|
286
|
-
end
|
287
|
-
end
|
141
|
+
it "should pass if target has a collection of items with n members" do
|
142
|
+
owner = create_collection_owner_with(3)
|
143
|
+
owner.should have_exactly(3).items_in_collection_with_length_method
|
144
|
+
owner.should have_exactly(3).items_in_collection_with_size_method
|
145
|
+
end
|
288
146
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
owner
|
147
|
+
it "should convert :no to 0" do
|
148
|
+
owner = create_collection_owner_with(0)
|
149
|
+
owner.should have_exactly(:no).items_in_collection_with_length_method
|
150
|
+
owner.should have_exactly(:no).items_in_collection_with_size_method
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should fail if target has a collection of items with < n members" do
|
154
|
+
owner = create_collection_owner_with(3)
|
155
|
+
lambda {
|
156
|
+
owner.should have_exactly(4).items_in_collection_with_length_method
|
157
|
+
}.should fail_with("expected 4 items_in_collection_with_length_method, got 3")
|
158
|
+
lambda {
|
159
|
+
owner.should have_exactly(4).items_in_collection_with_size_method
|
160
|
+
}.should fail_with("expected 4 items_in_collection_with_size_method, got 3")
|
297
161
|
end
|
298
|
-
owner
|
299
|
-
end
|
300
162
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
end
|
310
|
-
end
|
163
|
+
it "should fail if target has a collection of items with > n members" do
|
164
|
+
owner = create_collection_owner_with(3)
|
165
|
+
lambda {
|
166
|
+
owner.should have_exactly(2).items_in_collection_with_length_method
|
167
|
+
}.should fail_with("expected 2 items_in_collection_with_length_method, got 3")
|
168
|
+
lambda {
|
169
|
+
owner.should have_exactly(2).items_in_collection_with_size_method
|
170
|
+
}.should fail_with("expected 2 items_in_collection_with_size_method, got 3")
|
311
171
|
end
|
312
172
|
end
|
173
|
+
|
174
|
+
describe "should have_at_least(n).items" do
|
313
175
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
176
|
+
it "should pass if target has a collection of items with n members" do
|
177
|
+
owner = create_collection_owner_with(3)
|
178
|
+
owner.should have_at_least(3).items_in_collection_with_length_method
|
179
|
+
owner.should have_at_least(3).items_in_collection_with_size_method
|
180
|
+
end
|
319
181
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
182
|
+
it "should pass if target has a collection of items with > n members" do
|
183
|
+
owner = create_collection_owner_with(3)
|
184
|
+
owner.should have_at_least(2).items_in_collection_with_length_method
|
185
|
+
owner.should have_at_least(2).items_in_collection_with_size_method
|
186
|
+
end
|
325
187
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
188
|
+
it "should fail if target has a collection of items with < n members" do
|
189
|
+
owner = create_collection_owner_with(3)
|
190
|
+
lambda {
|
191
|
+
owner.should have_at_least(4).items_in_collection_with_length_method
|
192
|
+
}.should fail_with("expected at least 4 items_in_collection_with_length_method, got 3")
|
193
|
+
lambda {
|
194
|
+
owner.should have_at_least(4).items_in_collection_with_size_method
|
195
|
+
}.should fail_with("expected at least 4 items_in_collection_with_size_method, got 3")
|
196
|
+
end
|
335
197
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
198
|
+
it "should provide educational negative failure messages" do
|
199
|
+
#given
|
200
|
+
owner = create_collection_owner_with(3)
|
201
|
+
length_matcher = have_at_least(3).items_in_collection_with_length_method
|
202
|
+
size_matcher = have_at_least(3).items_in_collection_with_size_method
|
341
203
|
|
342
|
-
|
343
|
-
|
344
|
-
|
204
|
+
#when
|
205
|
+
length_matcher.matches?(owner)
|
206
|
+
size_matcher.matches?(owner)
|
345
207
|
|
346
|
-
|
347
|
-
|
208
|
+
#then
|
209
|
+
length_matcher.negative_failure_message.should == <<-EOF
|
348
210
|
Isn't life confusing enough?
|
349
211
|
Instead of having to figure out the meaning of this:
|
350
212
|
should_not have_at_least(3).items_in_collection_with_length_method
|
@@ -352,75 +214,52 @@ We recommend that you use this instead:
|
|
352
214
|
should have_at_most(2).items_in_collection_with_length_method
|
353
215
|
EOF
|
354
216
|
|
355
|
-
|
217
|
+
size_matcher.negative_failure_message.should == <<-EOF
|
356
218
|
Isn't life confusing enough?
|
357
219
|
Instead of having to figure out the meaning of this:
|
358
220
|
should_not have_at_least(3).items_in_collection_with_size_method
|
359
221
|
We recommend that you use this instead:
|
360
222
|
should have_at_most(2).items_in_collection_with_size_method
|
361
223
|
EOF
|
224
|
+
end
|
362
225
|
end
|
363
|
-
end
|
364
226
|
|
365
|
-
describe "should have_at_most(n).items" do
|
366
|
-
# include HaveMicronautHelper
|
227
|
+
describe "should have_at_most(n).items" do
|
367
228
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
owner.
|
372
|
-
owner.add_to_collection_with_size_method(n)
|
229
|
+
it "should pass if target has a collection of items with n members" do
|
230
|
+
owner = create_collection_owner_with(3)
|
231
|
+
owner.should have_at_most(3).items_in_collection_with_length_method
|
232
|
+
owner.should have_at_most(3).items_in_collection_with_size_method
|
373
233
|
end
|
374
|
-
owner
|
375
|
-
end
|
376
|
-
|
377
|
-
before do
|
378
|
-
unless defined?(ActiveSupport::Inflector)
|
379
|
-
@active_support_was_not_defined
|
380
|
-
module ActiveSupport
|
381
|
-
class Inflector
|
382
|
-
def self.pluralize(string)
|
383
|
-
string.to_s + 's'
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
it "should pass if target has a collection of items with n members" do
|
391
|
-
owner = create_collection_owner_with(3)
|
392
|
-
owner.should have_at_most(3).items_in_collection_with_length_method
|
393
|
-
owner.should have_at_most(3).items_in_collection_with_size_method
|
394
|
-
end
|
395
234
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
235
|
+
it "should fail if target has a collection of items with > n members" do
|
236
|
+
owner = create_collection_owner_with(3)
|
237
|
+
lambda {
|
238
|
+
owner.should have_at_most(2).items_in_collection_with_length_method
|
239
|
+
}.should fail_with("expected at most 2 items_in_collection_with_length_method, got 3")
|
240
|
+
lambda {
|
241
|
+
owner.should have_at_most(2).items_in_collection_with_size_method
|
242
|
+
}.should fail_with("expected at most 2 items_in_collection_with_size_method, got 3")
|
243
|
+
end
|
405
244
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
245
|
+
it "should pass if target has a collection of items with < n members" do
|
246
|
+
owner = create_collection_owner_with(3)
|
247
|
+
owner.should have_at_most(4).items_in_collection_with_length_method
|
248
|
+
owner.should have_at_most(4).items_in_collection_with_size_method
|
249
|
+
end
|
411
250
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
251
|
+
it "should provide educational negative failure messages" do
|
252
|
+
#given
|
253
|
+
owner = create_collection_owner_with(3)
|
254
|
+
length_matcher = have_at_most(3).items_in_collection_with_length_method
|
255
|
+
size_matcher = have_at_most(3).items_in_collection_with_size_method
|
417
256
|
|
418
|
-
|
419
|
-
|
420
|
-
|
257
|
+
#when
|
258
|
+
length_matcher.matches?(owner)
|
259
|
+
size_matcher.matches?(owner)
|
421
260
|
|
422
|
-
|
423
|
-
|
261
|
+
#then
|
262
|
+
length_matcher.negative_failure_message.should == <<-EOF
|
424
263
|
Isn't life confusing enough?
|
425
264
|
Instead of having to figure out the meaning of this:
|
426
265
|
should_not have_at_most(3).items_in_collection_with_length_method
|
@@ -428,148 +267,128 @@ We recommend that you use this instead:
|
|
428
267
|
should have_at_least(4).items_in_collection_with_length_method
|
429
268
|
EOF
|
430
269
|
|
431
|
-
|
270
|
+
size_matcher.negative_failure_message.should == <<-EOF
|
432
271
|
Isn't life confusing enough?
|
433
272
|
Instead of having to figure out the meaning of this:
|
434
273
|
should_not have_at_most(3).items_in_collection_with_size_method
|
435
274
|
We recommend that you use this instead:
|
436
275
|
should have_at_least(4).items_in_collection_with_size_method
|
437
276
|
EOF
|
277
|
+
end
|
438
278
|
end
|
439
|
-
end
|
440
279
|
|
441
|
-
describe "have(n).items(args, block)" do
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
280
|
+
describe "have(n).items(args, block)" do
|
281
|
+
it "should pass args to target" do
|
282
|
+
target = mock("target")
|
283
|
+
target.expects(:items).with("arg1","arg2").returns([1,2,3])
|
284
|
+
target.should have(3).items("arg1","arg2")
|
285
|
+
end
|
447
286
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
287
|
+
it "should pass block to target" do
|
288
|
+
target = mock("target")
|
289
|
+
block = lambda { 5 }
|
290
|
+
target.expects(:items).with("arg1","arg2", block).returns([1,2,3])
|
291
|
+
target.should have(3).items("arg1","arg2", block)
|
292
|
+
end
|
453
293
|
end
|
454
|
-
end
|
455
294
|
|
456
|
-
describe "have(n).items where target IS a collection" do
|
457
|
-
|
458
|
-
|
459
|
-
|
295
|
+
describe "have(n).items where target IS a collection" do
|
296
|
+
it "should reference the number of items IN the collection" do
|
297
|
+
[1,2,3].should have(3).items
|
298
|
+
end
|
460
299
|
|
461
|
-
|
462
|
-
|
300
|
+
it "should fail when the number of items IN the collection is not as expected" do
|
301
|
+
lambda { [1,2,3].should have(7).items }.should fail_with("expected 7 items, got 3")
|
302
|
+
end
|
463
303
|
end
|
464
|
-
end
|
465
304
|
|
466
|
-
describe "have(n).characters where target IS a String" do
|
467
|
-
|
468
|
-
|
469
|
-
|
305
|
+
describe "have(n).characters where target IS a String" do
|
306
|
+
it "should pass if the length is correct" do
|
307
|
+
"this string".should have(11).characters
|
308
|
+
end
|
470
309
|
|
471
|
-
|
472
|
-
|
310
|
+
it "should fail if the length is incorrect" do
|
311
|
+
lambda { "this string".should have(12).characters }.should fail_with("expected 12 characters, got 11")
|
312
|
+
end
|
473
313
|
end
|
474
|
-
end
|
475
314
|
|
476
|
-
describe "have(n).things on an object which is not a collection nor contains one" do
|
477
|
-
|
478
|
-
|
315
|
+
describe "have(n).things on an object which is not a collection nor contains one" do
|
316
|
+
it "should fail" do
|
317
|
+
lambda { Object.new.should have(2).things }.should raise_error(NoMethodError, /undefined method `things' for #<Object:/)
|
318
|
+
end
|
479
319
|
end
|
480
|
-
end
|
481
320
|
|
482
|
-
describe Micronaut::Matchers::Have, "for a collection owner that implements #send" do
|
483
|
-
# include HaveMicronautHelper
|
321
|
+
describe Micronaut::Matchers::Have, "for a collection owner that implements #send" do
|
484
322
|
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
owner.add_to_collection_with_size_method(n)
|
323
|
+
before do
|
324
|
+
@collection = Object.new
|
325
|
+
def @collection.floozles; [1,2] end
|
326
|
+
def @collection.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
490
327
|
end
|
491
|
-
owner
|
492
|
-
end
|
493
328
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
class Inflector
|
499
|
-
def self.pluralize(string)
|
500
|
-
string.to_s + 's'
|
501
|
-
end
|
502
|
-
end
|
503
|
-
end
|
329
|
+
it "should work in the straightforward case" do
|
330
|
+
lambda {
|
331
|
+
@collection.should have(2).floozles
|
332
|
+
}.should_not raise_error
|
504
333
|
end
|
505
|
-
end
|
506
|
-
|
507
|
-
before do
|
508
|
-
@collection = Object.new
|
509
|
-
def @collection.floozles; [1,2] end
|
510
|
-
def @collection.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
511
|
-
end
|
512
|
-
|
513
|
-
it "should work in the straightforward case" do
|
514
|
-
lambda {
|
515
|
-
@collection.should have(2).floozles
|
516
|
-
}.should_not raise_error
|
517
|
-
end
|
518
334
|
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
335
|
+
it "should work when doing automatic pluralization" do
|
336
|
+
lambda {
|
337
|
+
@collection.should have_at_least(1).floozle
|
338
|
+
}.should_not raise_error
|
339
|
+
end
|
524
340
|
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
341
|
+
it "should blow up when the owner doesn't respond to that method" do
|
342
|
+
lambda {
|
343
|
+
@collection.should have(99).problems
|
344
|
+
}.should raise_error(NoMethodError, /problems/)
|
345
|
+
end
|
529
346
|
end
|
530
|
-
|
531
|
-
|
532
|
-
module
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
# end
|
542
|
-
end
|
543
|
-
|
544
|
-
describe "respond_to?" do
|
545
|
-
before :each do
|
546
|
-
@have = Have.new(:foo)
|
547
|
-
@a_method_which_have_defines = Have.instance_methods.first
|
548
|
-
@a_method_which_object_defines = Object.instance_methods.first
|
347
|
+
|
348
|
+
module Micronaut
|
349
|
+
module Matchers
|
350
|
+
describe Have do
|
351
|
+
it "should have method_missing as private" do
|
352
|
+
# with_ruby '1.8' do
|
353
|
+
Have.private_instance_methods.should include("method_missing")
|
354
|
+
# end
|
355
|
+
# with_ruby '1.9' do
|
356
|
+
# Have.private_instance_methods.should include(:method_missing)
|
357
|
+
# end
|
549
358
|
end
|
359
|
+
|
360
|
+
describe "respond_to?" do
|
361
|
+
before :each do
|
362
|
+
@have = Have.new(:foo)
|
363
|
+
@a_method_which_have_defines = Have.instance_methods.first
|
364
|
+
@a_method_which_object_defines = Object.instance_methods.first
|
365
|
+
end
|
550
366
|
|
551
|
-
|
552
|
-
|
553
|
-
|
367
|
+
it "should be true for a method which Have defines" do
|
368
|
+
@have.should respond_to(@a_method_which_have_defines)
|
369
|
+
end
|
554
370
|
|
555
|
-
|
556
|
-
|
557
|
-
|
371
|
+
it "should be true for a method that it's superclass (Object) defines" do
|
372
|
+
@have.should respond_to(@a_method_which_object_defines)
|
373
|
+
end
|
558
374
|
|
559
|
-
|
560
|
-
|
561
|
-
|
375
|
+
it "should be false for a method which neither Object nor nor Have defines" do
|
376
|
+
@have.should_not respond_to(:foo_bar_baz)
|
377
|
+
end
|
562
378
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
379
|
+
it "should be false if the owner doesn't respond to the method" do
|
380
|
+
have = Have.new(99)
|
381
|
+
have.should_not respond_to(:problems)
|
382
|
+
end
|
567
383
|
|
568
|
-
|
569
|
-
|
570
|
-
|
384
|
+
it "should be true if the owner responds to the method" do
|
385
|
+
have = Have.new(:a_symbol)
|
386
|
+
have.should respond_to(:to_sym)
|
387
|
+
end
|
571
388
|
end
|
572
389
|
end
|
573
390
|
end
|
391
|
+
|
574
392
|
end
|
575
|
-
|
393
|
+
|
394
|
+
end
|
@@ -37,6 +37,13 @@ describe Micronaut::World do
|
|
37
37
|
end
|
38
38
|
@behaviours = [@bg1, @bg2, @bg3, @bg4]
|
39
39
|
end
|
40
|
+
|
41
|
+
after(:all) do
|
42
|
+
Micronaut.world.behaviours.delete(@bg1)
|
43
|
+
Micronaut.world.behaviours.delete(@bg2)
|
44
|
+
Micronaut.world.behaviours.delete(@bg3)
|
45
|
+
Micronaut.world.behaviours.delete(@bg4)
|
46
|
+
end
|
40
47
|
|
41
48
|
it "should find awesome examples" do
|
42
49
|
@world.find(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
|
@@ -108,11 +108,11 @@ module Micronaut
|
|
108
108
|
return "" if backtrace.nil?
|
109
109
|
cleansed = backtrace.map { |line| backtrace_line(line) }.compact
|
110
110
|
original_file = example.behaviour.metadata[:behaviour][:file_path].split(':').first.strip
|
111
|
+
|
111
112
|
cleansed = cleansed.select do |line|
|
112
113
|
line.split(':').first.downcase == original_file.downcase
|
113
114
|
end
|
114
|
-
|
115
|
-
# junk
|
115
|
+
|
116
116
|
cleansed.empty? ? backtrace : cleansed
|
117
117
|
end
|
118
118
|
|
@@ -15,7 +15,9 @@ module Micronaut
|
|
15
15
|
|
16
16
|
described_behaviour_chain.each_with_index do |nested_behaviour, i|
|
17
17
|
unless nested_behaviour == previous_nested_behaviours[i]
|
18
|
-
|
18
|
+
at_root_level = (i == 0)
|
19
|
+
desc_or_name = at_root_level ? nested_behaviour.name : nested_behaviour.description
|
20
|
+
output.puts if at_root_level
|
19
21
|
output.puts "#{' ' * i}#{desc_or_name}"
|
20
22
|
end
|
21
23
|
end
|
data/lib/micronaut/world.rb
CHANGED
@@ -50,6 +50,8 @@ module Micronaut
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def apply_condition(filter_on, filter, metadata)
|
53
|
+
return false if metadata.nil?
|
54
|
+
|
53
55
|
case filter
|
54
56
|
when Hash
|
55
57
|
filter.all? { |k, v| apply_condition(k, v, metadata[filter_on]) }
|
@@ -64,4 +66,4 @@ module Micronaut
|
|
64
66
|
|
65
67
|
end
|
66
68
|
|
67
|
-
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spicycode-micronaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.6.
|
4
|
+
version: 0.1.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Humphries
|
@@ -9,7 +9,7 @@ autorequire: micronaut
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-25 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|