spicycode-micronaut 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 2
@@ -37,4 +37,5 @@ Micronaut.configure do |c|
37
37
  c.mock_with :mocha
38
38
  c.color_enabled = not_in_editor?
39
39
  c.filter_run :focused => true
40
+ c.formatter = :documentation
40
41
  end
@@ -2,12 +2,18 @@ require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
2
2
 
3
3
  describe Micronaut::Behaviour do
4
4
 
5
+ before(:all) { puts "ba: describe Micronaut::Behaviour" }
6
+ after(:all) { puts "aa: describe Micronaut::Behaviour" }
7
+
5
8
  def empty_behaviour_group
6
9
  group = Micronaut::Behaviour.describe(Object, 'Empty Behaviour Group') { }
7
10
  remove_last_describe_from_world
8
11
  end
9
12
 
10
13
  describe "describing behaviour with #describe" do
14
+
15
+ before(:all) { puts "ba: describing behaviour with #describe" }
16
+ after(:all) { puts "aa: describing behaviour with #describe" }
11
17
 
12
18
  example "an ArgumentError is raised if no type or description is given" do
13
19
  lambda { Micronaut::Behaviour.describe() {} }.should raise_error(ArgumentError, "No arguments given. You must a least supply a type or description")
@@ -21,10 +27,12 @@ describe Micronaut::Behaviour do
21
27
 
22
28
  it "should expose the first parameter as name" do
23
29
  Micronaut::Behaviour.describe("my favorite pony") { }.name.should == 'my favorite pony'
30
+ remove_last_describe_from_world
24
31
  end
25
32
 
26
33
  it "should call to_s on the first parameter in case it is a constant" do
27
34
  Micronaut::Behaviour.describe(Object) { }.name.should == 'Object'
35
+ remove_last_describe_from_world
28
36
  end
29
37
 
30
38
  end
@@ -33,10 +41,12 @@ describe Micronaut::Behaviour do
33
41
 
34
42
  it "should be the first parameter when it is a constant" do
35
43
  Micronaut::Behaviour.describe(Object) { }.describes.should == Object
44
+ remove_last_describe_from_world
36
45
  end
37
46
 
38
47
  it "should be nil when the first parameter is a string" do
39
48
  Micronaut::Behaviour.describe("i'm a computer") { }.describes.should be_nil
49
+ remove_last_describe_from_world
40
50
  end
41
51
 
42
52
  end
@@ -45,36 +55,43 @@ describe Micronaut::Behaviour do
45
55
 
46
56
  it "should expose the second parameter as description" do
47
57
  Micronaut::Behaviour.describe(Object, "my desc") { }.description.should == 'my desc'
58
+ remove_last_describe_from_world
48
59
  end
49
-
60
+
50
61
  it "should allow the second parameter to be nil" do
51
62
  Micronaut::Behaviour.describe(Object, nil) { }.description.size.should == 0
63
+ remove_last_describe_from_world
52
64
  end
53
65
 
54
66
  end
55
67
 
56
68
  describe '#metadata' do
57
-
69
+
58
70
  it "should add the third parameter to the metadata" do
59
71
  Micronaut::Behaviour.describe(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
72
+ remove_last_describe_from_world
60
73
  end
61
-
74
+
62
75
  it "should add the caller to metadata" do
63
76
  Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:caller][4].should =~ /#{__FILE__}:#{__LINE__}/
77
+ remove_last_describe_from_world
64
78
  end
65
-
79
+
66
80
  it "should add the the file_path to metadata" do
67
81
  Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path].should == __FILE__
82
+ remove_last_describe_from_world
68
83
  end
69
-
84
+
70
85
  it "should have a reader for file_path" do
71
86
  Micronaut::Behaviour.describe(Object) { }.file_path.should == __FILE__
87
+ remove_last_describe_from_world
72
88
  end
73
-
89
+
74
90
  it "should add the line_number to metadata" do
75
91
  Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
92
+ remove_last_describe_from_world
76
93
  end
77
-
94
+
78
95
  it "should add file path and line number metadata for arbitrarily nested describes" do
79
96
  Micronaut::Behaviour.describe(Object) do
80
97
  Micronaut::Behaviour.describe("foo") do
@@ -82,8 +99,12 @@ describe Micronaut::Behaviour do
82
99
  Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
83
100
  end
84
101
  end
102
+ remove_last_describe_from_world
103
+ remove_last_describe_from_world
104
+ remove_last_describe_from_world
105
+ remove_last_describe_from_world
85
106
  end
86
-
107
+
87
108
  end
88
109
 
89
110
  describe "adding before and after hooks" do
@@ -191,19 +212,19 @@ describe Micronaut::Behaviour do
191
212
  describe Object, "describing nested behaviours", :little_less_nested => 'yep' do
192
213
 
193
214
  describe "A sample nested describe", :nested_describe => "yep" do
194
-
215
+
195
216
  it "should set the described type to the constant Object" do
196
217
  running_example.behaviour.describes.should == Object
197
218
  end
198
-
219
+
199
220
  it "should set the description to 'A sample nested describe'" do
200
221
  running_example.behaviour.description.should == 'A sample nested describe'
201
222
  end
202
-
223
+
203
224
  it "should have top level metadata from the behaviour and its ancestors" do
204
225
  running_example.behaviour.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
205
226
  end
206
-
227
+
207
228
  it "should make the parent metadata available on the contained examples" do
208
229
  running_example.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
209
230
  end
@@ -211,9 +232,9 @@ describe Micronaut::Behaviour do
211
232
  end
212
233
 
213
234
  end
214
-
235
+
215
236
  describe "#run_examples" do
216
-
237
+
217
238
  def stub_behaviour
218
239
  stub_everything('behaviour', :metadata => { :behaviour => { :name => 'behaviour_name' }})
219
240
  end
@@ -225,7 +246,7 @@ describe Micronaut::Behaviour do
225
246
 
226
247
  Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter')).should == true
227
248
  end
228
-
249
+
229
250
  it "should return false if any of the examples return false" do
230
251
  failing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
231
252
  passing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
@@ -233,17 +254,49 @@ describe Micronaut::Behaviour do
233
254
 
234
255
  Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter')).should == false
235
256
  end
236
-
257
+
237
258
  it "should run all examples, regardless of any of them failing" do
238
259
  failing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
239
260
  passing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
240
261
  Micronaut::Behaviour.stubs(:examples_to_run).returns([failing_example, passing_example])
241
262
 
242
263
  passing_example.expects(:run)
243
-
264
+
244
265
  Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter'))
245
266
  end
246
-
267
+
247
268
  end
248
269
 
270
+ describe "how instance variables inherit" do
271
+
272
+ before do
273
+ @before_each_top_level = 'before_each_top_level'
274
+ end
275
+
276
+ before(:all) do
277
+ @before_all_top_level = 'before_all_top_level'
278
+ end
279
+
280
+ it "should be able to access a before each ivar at the same level" do
281
+ @before_each_top_level.should == 'before_each_top_level'
282
+ end
283
+
284
+ it "should be able to access a before all ivar at the same level" do
285
+ @before_all_top_level.should == 'before_all_top_level'
286
+ end
287
+
288
+ describe "but now I am nested" do
289
+
290
+ it "should be able to access a parent behaviours before each ivar at a nested level" do
291
+ @before_each_top_level.should == 'before_each_top_level'
292
+ end
293
+
294
+ it "should not be able to access a parent behaviours before all ivar at a nested level (YET)" do
295
+ @before_all_top_level.should be_nil
296
+ end
297
+
298
+ end
299
+
300
+ end
301
+
249
302
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
3
  describe Micronaut::Formatters::BaseFormatter do
4
4
 
5
- before(:all) do
5
+ before do
6
6
  @formatter = Micronaut::Formatters::BaseFormatter.new
7
7
  end
8
8
 
@@ -158,10 +158,8 @@ module Micronaut
158
158
 
159
159
  def self.eval_before_alls(running_behaviour)
160
160
  Micronaut.configuration.find_before_or_after(:before, :all, self).each { |blk| running_behaviour.instance_eval(&blk) }
161
-
162
- before_ancestors.each do |ancestor|
163
- ancestor.before_alls.each { |blk| running_behaviour.instance_eval(&blk) }
164
- end
161
+
162
+ before_alls.each { |blk| running_behaviour.instance_eval(&blk) }
165
163
  end
166
164
 
167
165
  def self.eval_before_eachs(running_behaviour)
@@ -173,9 +171,7 @@ module Micronaut
173
171
  end
174
172
 
175
173
  def self.eval_after_alls(running_behaviour)
176
- after_ancestors.each do |ancestor|
177
- ancestor.after_alls.each { |blk| running_behaviour.instance_eval(&blk) }
178
- end
174
+ after_alls.each { |blk| running_behaviour.instance_eval(&blk) }
179
175
 
180
176
  Micronaut.configuration.find_before_or_after(:after, :all, self).each { |blk| running_behaviour.instance_eval(&blk) }
181
177
  end
@@ -189,8 +185,6 @@ module Micronaut
189
185
  end
190
186
 
191
187
  def self.run(reporter)
192
- return true if examples.empty?
193
-
194
188
  behaviour_instance = new
195
189
  reporter.add_behaviour(self)
196
190
  eval_before_alls(behaviour_instance)
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-09 00:00:00 -08:00
12
+ date: 2009-02-10 00:00:00 -08:00
13
13
  default_executable: micronaut
14
14
  dependencies: []
15
15