spicycode-micronaut 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/examples/example_helper.rb +8 -1
- data/examples/lib/micronaut/behaviour_example.rb +24 -14
- data/examples/lib/micronaut/example_example.rb +6 -7
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +0 -4
- data/examples/lib/micronaut/mocha_example.rb +29 -0
- data/lib/micronaut/configuration.rb +1 -1
- data/lib/micronaut/example.rb +7 -13
- data/lib/micronaut/formatters/base_formatter.rb +1 -4
- data/lib/micronaut/mocking/with_mocha.rb +3 -1
- metadata +3 -2
data/VERSION.yml
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -35,6 +35,14 @@ def isolate_behaviour
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def use_formatter(new_formatter)
|
39
|
+
original_formatter = Micronaut.configuration.formatter
|
40
|
+
Micronaut.configuration.instance_variable_set(:@formatter, new_formatter)
|
41
|
+
yield
|
42
|
+
ensure
|
43
|
+
Micronaut.configuration.instance_variable_set(:@formatter, original_formatter)
|
44
|
+
end
|
45
|
+
|
38
46
|
def not_in_editor?
|
39
47
|
!(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
|
40
48
|
end
|
@@ -44,5 +52,4 @@ Micronaut.configure do |c|
|
|
44
52
|
c.color_enabled = not_in_editor?
|
45
53
|
c.filter_run :focused => true
|
46
54
|
c.profile_examples = true
|
47
|
-
#c.formatter = :documentation
|
48
55
|
end
|
@@ -236,36 +236,46 @@ describe Micronaut::Behaviour do
|
|
236
236
|
|
237
237
|
end
|
238
238
|
|
239
|
-
|
239
|
+
describe "#run_examples" do
|
240
|
+
|
241
|
+
before do
|
242
|
+
@fake_formatter = Micronaut::Formatters::BaseFormatter.new
|
243
|
+
end
|
240
244
|
|
241
245
|
def stub_behaviour
|
242
246
|
stub_everything('behaviour', :metadata => { :behaviour => { :name => 'behaviour_name' }})
|
243
247
|
end
|
244
248
|
|
245
249
|
it "should return true if all examples pass" do
|
246
|
-
|
247
|
-
|
248
|
-
|
250
|
+
use_formatter(@fake_formatter) do
|
251
|
+
passing_example1 = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
|
252
|
+
passing_example2 = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
|
253
|
+
Micronaut::Behaviour.stubs(:examples_to_run).returns([passing_example1, passing_example2])
|
249
254
|
|
250
|
-
|
255
|
+
Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter')).should be_true
|
256
|
+
end
|
251
257
|
end
|
252
258
|
|
253
259
|
it "should return false if any of the examples return false" do
|
254
|
-
|
255
|
-
|
256
|
-
|
260
|
+
use_formatter(@fake_formatter) do
|
261
|
+
failing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
|
262
|
+
passing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
|
263
|
+
Micronaut::Behaviour.stubs(:examples_to_run).returns([failing_example, passing_example])
|
257
264
|
|
258
|
-
|
265
|
+
Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter')).should be_false
|
266
|
+
end
|
259
267
|
end
|
260
268
|
|
261
269
|
it "should run all examples, regardless of any of them failing" do
|
262
|
-
|
263
|
-
|
264
|
-
|
270
|
+
use_formatter(@fake_formatter) do
|
271
|
+
failing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
|
272
|
+
passing_example = Micronaut::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
|
273
|
+
Micronaut::Behaviour.stubs(:examples_to_run).returns([failing_example, passing_example])
|
265
274
|
|
266
|
-
|
275
|
+
passing_example.expects(:run)
|
267
276
|
|
268
|
-
|
277
|
+
Micronaut::Behaviour.run_examples(stub_behaviour, stub_everything('reporter'))
|
278
|
+
end
|
269
279
|
end
|
270
280
|
|
271
281
|
end
|
@@ -6,7 +6,7 @@ describe Micronaut::Example, :parent_metadata => 'sample' do
|
|
6
6
|
behaviour = stub('behaviour', :metadata => { :behaviour => { :name => 'behaviour_name' }})
|
7
7
|
@example = Micronaut::Example.new(behaviour, 'description', {}, (lambda {}))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe "attr readers" do
|
11
11
|
|
12
12
|
it "should have one for the parent behaviour" do
|
@@ -24,7 +24,7 @@ describe Micronaut::Example, :parent_metadata => 'sample' do
|
|
24
24
|
it "should have one for it's block" do
|
25
25
|
@example.should respond_to(:example_block)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#inspect' do
|
@@ -44,11 +44,11 @@ describe Micronaut::Example, :parent_metadata => 'sample' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "accessing metadata within a running example" do
|
47
|
-
|
47
|
+
|
48
48
|
it "should have a reference to itself when running" do
|
49
49
|
running_example.description.should == "should have a reference to itself when running"
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it "should be able to access the behaviours top level metadata as if it were its own" do
|
53
53
|
running_example.behaviour.metadata.should include(:parent_metadata => 'sample')
|
54
54
|
running_example.metadata.should include(:parent_metadata => 'sample')
|
@@ -59,10 +59,9 @@ describe Micronaut::Example, :parent_metadata => 'sample' do
|
|
59
59
|
describe "#run" do
|
60
60
|
|
61
61
|
pending "should run after(:each) when the example fails"
|
62
|
-
|
62
|
+
|
63
63
|
pending "should run after(:each) when the example raises an Exception"
|
64
64
|
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
end
|
67
|
+
end
|
@@ -72,10 +72,6 @@ describe Micronaut::Formatters::BaseFormatter do
|
|
72
72
|
@formatter.should have_interface_for(:add_behaviour).with(1).argument
|
73
73
|
end
|
74
74
|
|
75
|
-
it "should have example_started as an interface with one argument" do
|
76
|
-
@formatter.should have_interface_for(:example_started).with(1).argument
|
77
|
-
end
|
78
|
-
|
79
75
|
it "should have example_finished as an interface with one argument" do
|
80
76
|
@formatter.should have_interface_for(:example_finished).with(1).arguments
|
81
77
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
describe "Mocha Regression involving double reporting of errors" do
|
4
|
+
|
5
|
+
it "should not double report mocha errors" do
|
6
|
+
# The below example should have one error, not two
|
7
|
+
# I'm also not sure how to test this regression without having the failure counting by
|
8
|
+
# the running Micronaut instance
|
9
|
+
formatter = Micronaut::Formatters::BaseFormatter.new
|
10
|
+
|
11
|
+
use_formatter(formatter) do
|
12
|
+
|
13
|
+
isolate_behaviour do
|
14
|
+
desc = Micronaut::Behaviour.describe("my favorite pony") do
|
15
|
+
example("showing a double fail") do
|
16
|
+
foo = "string"
|
17
|
+
foo.expects(:something)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
desc.examples_to_run.replace(desc.examples)
|
21
|
+
desc.run(formatter)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
formatter.examples.size.should == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/micronaut/example.rb
CHANGED
@@ -22,7 +22,6 @@ module Micronaut
|
|
22
22
|
|
23
23
|
def run_started
|
24
24
|
record_results :started_at => Time.now
|
25
|
-
Micronaut.configuration.formatter.example_started(self)
|
26
25
|
end
|
27
26
|
|
28
27
|
def run_passed
|
@@ -56,15 +55,6 @@ module Micronaut
|
|
56
55
|
@behaviour_instance._teardown_mocks if @behaviour_instance.respond_to?(:_teardown_mocks)
|
57
56
|
end
|
58
57
|
|
59
|
-
def run_example
|
60
|
-
if example_block
|
61
|
-
@behaviour_instance.instance_eval(&example_block)
|
62
|
-
run_passed
|
63
|
-
else
|
64
|
-
run_pending
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
58
|
def run(behaviour_instance)
|
69
59
|
@behaviour_instance = behaviour_instance
|
70
60
|
@behaviour_instance.running_example = self
|
@@ -76,7 +66,7 @@ module Micronaut
|
|
76
66
|
|
77
67
|
begin
|
78
68
|
run_before_each
|
79
|
-
|
69
|
+
@behaviour_instance.instance_eval(&example_block) if example_block
|
80
70
|
rescue Exception => e
|
81
71
|
exception_encountered = e
|
82
72
|
all_systems_nominal = false
|
@@ -90,8 +80,12 @@ module Micronaut
|
|
90
80
|
ensure
|
91
81
|
@behaviour_instance.running_example = nil
|
92
82
|
end
|
93
|
-
|
94
|
-
|
83
|
+
|
84
|
+
if exception_encountered
|
85
|
+
run_failed(exception_encountered)
|
86
|
+
else
|
87
|
+
example_block ? run_passed : run_pending
|
88
|
+
end
|
95
89
|
|
96
90
|
all_systems_nominal
|
97
91
|
end
|
@@ -54,9 +54,6 @@ module Micronaut
|
|
54
54
|
@example_count = example_count
|
55
55
|
end
|
56
56
|
|
57
|
-
def example_started(example)
|
58
|
-
end
|
59
|
-
|
60
57
|
def example_finished(example)
|
61
58
|
examples << example
|
62
59
|
end
|
@@ -111,7 +108,7 @@ module Micronaut
|
|
111
108
|
end
|
112
109
|
|
113
110
|
def read_failed_line(exception, example)
|
114
|
-
original_file = example.behaviour.file_path.downcase
|
111
|
+
original_file = example.behaviour.file_path.to_s.downcase
|
115
112
|
matching_line = exception.backtrace.detect { |line| line.split(':').first.downcase == original_file.downcase }
|
116
113
|
|
117
114
|
return "Unable to find matching line from backtrace" if matching_line.nil?
|
@@ -5,9 +5,11 @@ module Micronaut
|
|
5
5
|
module Mocking
|
6
6
|
module WithMocha
|
7
7
|
include Mocha::Standalone
|
8
|
+
|
8
9
|
alias :_setup_mocks :mocha_setup
|
9
10
|
alias :_verify_mocks :mocha_verify
|
10
|
-
alias :_teardown_mocks :mocha_teardown
|
11
|
+
alias :_teardown_mocks :mocha_teardown
|
12
|
+
|
11
13
|
end
|
12
14
|
end
|
13
15
|
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.2.
|
4
|
+
version: 0.2.7
|
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-03-
|
12
|
+
date: 2009-03-27 00:00:00 -07:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- examples/lib/micronaut/matchers/satisfy_example.rb
|
109
109
|
- examples/lib/micronaut/matchers/simple_matcher_example.rb
|
110
110
|
- examples/lib/micronaut/matchers/throw_symbol_example.rb
|
111
|
+
- examples/lib/micronaut/mocha_example.rb
|
111
112
|
- examples/lib/micronaut/runner_example.rb
|
112
113
|
- examples/lib/micronaut/world_example.rb
|
113
114
|
- examples/lib/micronaut_example.rb
|