spicycode-micronaut 0.1.8.3 → 0.1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/examples/example_helper.rb +7 -5
- data/lib/micronaut/behaviour.rb +12 -40
- data/lib/micronaut/example.rb +49 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems/specification'
|
|
4
4
|
require 'lib/micronaut/rake_task'
|
5
5
|
|
6
6
|
GEM = "micronaut"
|
7
|
-
GEM_VERSION = "0.1.8.
|
7
|
+
GEM_VERSION = "0.1.8.5"
|
8
8
|
AUTHOR = "Chad Humphries"
|
9
9
|
EMAIL = "chad@spicycode.com"
|
10
10
|
HOMEPAGE = "http://github.com/spicycode/micronaut"
|
@@ -72,4 +72,4 @@ namespace :examples do
|
|
72
72
|
|
73
73
|
end
|
74
74
|
|
75
|
-
task :default => 'examples:coverage'
|
75
|
+
task :default => 'examples:coverage'
|
data/examples/example_helper.rb
CHANGED
@@ -3,8 +3,14 @@ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
|
3
3
|
|
4
4
|
require 'micronaut'
|
5
5
|
require 'rubygems'
|
6
|
-
gem :mocha
|
7
6
|
|
7
|
+
def with_ruby(version)
|
8
|
+
yield if RUBY_PLATFORM =~ Regexp.compile("^#{version}")
|
9
|
+
end
|
10
|
+
|
11
|
+
with_ruby("1.8") do
|
12
|
+
gem :mocha
|
13
|
+
end
|
8
14
|
require File.expand_path(File.dirname(__FILE__) + "/resources/example_classes")
|
9
15
|
|
10
16
|
module Micronaut
|
@@ -19,10 +25,6 @@ module Micronaut
|
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
22
|
-
def with_ruby(version)
|
23
|
-
yield if RUBY_PLATFORM =~ Regexp.compile("^#{version}")
|
24
|
-
end
|
25
|
-
|
26
28
|
def remove_last_describe_from_world
|
27
29
|
Micronaut.world.behaviours.pop
|
28
30
|
end
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -2,7 +2,7 @@ module Micronaut
|
|
2
2
|
class Behaviour
|
3
3
|
include Micronaut::Matchers
|
4
4
|
|
5
|
-
attr_accessor :running_example
|
5
|
+
attr_accessor :running_example, :reporter
|
6
6
|
|
7
7
|
def self.inherited(klass)
|
8
8
|
super
|
@@ -103,23 +103,23 @@ module Micronaut
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def self.metadata
|
106
|
-
@metadata
|
106
|
+
@metadata ||= { :behaviour => {} }
|
107
107
|
end
|
108
108
|
|
109
109
|
def self.name
|
110
|
-
|
110
|
+
metadata[:behaviour][:name]
|
111
111
|
end
|
112
112
|
|
113
113
|
def self.describes
|
114
|
-
|
114
|
+
metadata[:behaviour][:describes]
|
115
115
|
end
|
116
116
|
|
117
117
|
def self.description
|
118
|
-
|
118
|
+
metadata[:behaviour][:description]
|
119
119
|
end
|
120
120
|
|
121
121
|
def self.file_path
|
122
|
-
|
122
|
+
metadata[:behaviour][:file_path]
|
123
123
|
end
|
124
124
|
|
125
125
|
def self.describe(*args, &behaviour_block)
|
@@ -191,40 +191,12 @@ module Micronaut
|
|
191
191
|
def self.run(reporter)
|
192
192
|
return true if examples.empty?
|
193
193
|
|
194
|
+
behaviour_instance = new
|
194
195
|
reporter.add_behaviour(self)
|
196
|
+
eval_before_alls(behaviour_instance)
|
197
|
+
success = examples_to_run.all? { |ex| ex.run(behaviour_instance, reporter) }
|
198
|
+
eval_after_alls(behaviour_instance)
|
195
199
|
|
196
|
-
group = new
|
197
|
-
eval_before_alls(group)
|
198
|
-
success = true
|
199
|
-
|
200
|
-
examples_to_run.each do |ex|
|
201
|
-
group.running_example = ex
|
202
|
-
reporter.example_started(ex)
|
203
|
-
|
204
|
-
execution_error = nil
|
205
|
-
begin
|
206
|
-
group._setup_mocks
|
207
|
-
eval_before_eachs(group)
|
208
|
-
|
209
|
-
if ex.example_block
|
210
|
-
group.instance_eval(&ex.example_block)
|
211
|
-
group._verify_mocks
|
212
|
-
reporter.example_passed(ex)
|
213
|
-
else
|
214
|
-
reporter.example_pending(ex, 'Not yet implemented')
|
215
|
-
end
|
216
|
-
rescue Exception => e
|
217
|
-
reporter.example_failed(ex, e)
|
218
|
-
execution_error ||= e
|
219
|
-
ensure
|
220
|
-
eval_after_eachs(group)
|
221
|
-
group._teardown_mocks
|
222
|
-
end
|
223
|
-
|
224
|
-
success &= execution_error.nil?
|
225
|
-
end
|
226
|
-
eval_after_alls(group)
|
227
|
-
group.running_example = nil
|
228
200
|
success
|
229
201
|
end
|
230
202
|
|
@@ -239,8 +211,8 @@ module Micronaut
|
|
239
211
|
end
|
240
212
|
|
241
213
|
def self.to_s
|
242
|
-
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' :
|
214
|
+
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' : name
|
243
215
|
end
|
244
216
|
|
245
217
|
end
|
246
|
-
end
|
218
|
+
end
|
data/lib/micronaut/example.rb
CHANGED
@@ -18,6 +18,55 @@ module Micronaut
|
|
18
18
|
def to_s
|
19
19
|
inspect
|
20
20
|
end
|
21
|
+
|
22
|
+
def run_before_each
|
23
|
+
@behaviour_instance._setup_mocks
|
24
|
+
@behaviour.eval_before_eachs(@behaviour_instance)
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_after_each
|
28
|
+
@behaviour.eval_after_eachs(@behaviour_instance)
|
29
|
+
@behaviour_instance._verify_mocks
|
30
|
+
ensure
|
31
|
+
@behaviour_instance._teardown_mocks
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_example
|
35
|
+
if example_block
|
36
|
+
@behaviour_instance.instance_eval(&example_block)
|
37
|
+
@behaviour_instance._verify_mocks
|
38
|
+
@reporter.example_passed(self)
|
39
|
+
else
|
40
|
+
@reporter.example_pending(self, 'Not yet implemented')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def run(behaviour_instance, reporter)
|
45
|
+
@behaviour_instance, @reporter = behaviour_instance, reporter
|
46
|
+
@behaviour_instance.running_example = self
|
47
|
+
@reporter.example_started(self)
|
48
|
+
|
49
|
+
all_systems_nominal = true
|
50
|
+
|
51
|
+
begin
|
52
|
+
run_before_each
|
53
|
+
run_example
|
54
|
+
rescue Exception => e
|
55
|
+
@reporter.example_failed(self, e)
|
56
|
+
all_systems_nominal = false
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
run_after_each
|
61
|
+
rescue Exception => e
|
62
|
+
@reporter.example_failed(self, e)
|
63
|
+
all_systems_nominal = false
|
64
|
+
ensure
|
65
|
+
@behaviour_instance.running_example = nil
|
66
|
+
end
|
67
|
+
|
68
|
+
all_systems_nominal
|
69
|
+
end
|
21
70
|
|
22
71
|
end
|
23
72
|
|
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.8.
|
4
|
+
version: 0.1.8.5
|
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: 2009-01-
|
12
|
+
date: 2009-01-05 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|