spicycode-micronaut 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -2
- data/bin/micronaut +4 -0
- data/examples/example_helper.rb +3 -4
- data/examples/lib/micronaut/configuration_example.rb +2 -2
- data/examples/lib/micronaut/world_example.rb +20 -19
- data/lib/autotest/micronaut.rb +1 -2
- data/lib/micronaut/behaviour.rb +11 -3
- data/lib/micronaut/configuration.rb +9 -1
- data/lib/micronaut/example.rb +7 -0
- data/lib/micronaut/runner.rb +30 -27
- data/lib/micronaut/world.rb +32 -15
- metadata +6 -5
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems/specification'
|
|
4
4
|
require 'date'
|
5
5
|
|
6
6
|
GEM = "micronaut"
|
7
|
-
GEM_VERSION = "0.1.
|
7
|
+
GEM_VERSION = "0.1.2"
|
8
8
|
AUTHOR = "Chad Humphries"
|
9
9
|
EMAIL = "chad@spicycode.com"
|
10
10
|
HOMEPAGE = "http://spicycode.com"
|
@@ -21,7 +21,9 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.author = AUTHOR
|
22
22
|
s.email = EMAIL
|
23
23
|
s.homepage = HOMEPAGE
|
24
|
-
|
24
|
+
s.bindir = 'bin'
|
25
|
+
s.default_executable = 'micronaut'
|
26
|
+
s.executables = ["micronaut"]
|
25
27
|
s.require_path = 'lib'
|
26
28
|
s.autorequire = GEM
|
27
29
|
s.files = %w(LICENSE README RSPEC-LICENSE Rakefile) + Dir.glob("{lib,examples}/**/*")
|
data/bin/micronaut
ADDED
data/examples/example_helper.rb
CHANGED
@@ -18,7 +18,7 @@ module Micronaut
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def remove_last_describe_from_world
|
21
|
-
Micronaut::World.
|
21
|
+
Micronaut::World.behaviours.pop
|
22
22
|
end
|
23
23
|
|
24
24
|
class DummyFormatter < Micronaut::Formatters::BaseTextFormatter; end
|
@@ -28,9 +28,8 @@ def dummy_reporter
|
|
28
28
|
end
|
29
29
|
|
30
30
|
Micronaut.configure do |config|
|
31
|
-
|
32
31
|
config.mock_with :mocha
|
32
|
+
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :documentation)
|
33
|
+
config.add_filter :options => { :focused => true }
|
33
34
|
config.autorun!
|
34
|
-
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :progress)
|
35
|
-
|
36
35
|
end
|
@@ -40,12 +40,12 @@ describe Micronaut::Configuration do
|
|
40
40
|
module FocusedSupport
|
41
41
|
|
42
42
|
def fit(desc, options={}, &block)
|
43
|
-
it(desc, options.
|
43
|
+
it(desc, options.update(:focused => true), &block)
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
focused "should extend the given module into each behaviour group" do
|
49
49
|
Micronaut.configuration.extend(FocusedSupport)
|
50
50
|
group = Micronaut::Behaviour.describe(FocusedSupport, 'the focused support ') { }
|
51
51
|
group.should respond_to(:fit)
|
@@ -8,7 +8,7 @@ describe Micronaut::World do
|
|
8
8
|
|
9
9
|
it "should contain all defined behaviour groups" do
|
10
10
|
behaviour_group = Micronaut::Behaviour.describe(Bar, 'Empty Behaviour Group') { }
|
11
|
-
Micronaut::World.
|
11
|
+
Micronaut::World.behaviours.should include(behaviour_group)
|
12
12
|
remove_last_describe_from_world
|
13
13
|
end
|
14
14
|
|
@@ -23,56 +23,57 @@ describe Micronaut::World do
|
|
23
23
|
@bg1 = Micronaut::Behaviour.describe(Bar, "find group-1", options_1) { }
|
24
24
|
@bg2 = Micronaut::Behaviour.describe(Bar, "find group-2", options_2) { }
|
25
25
|
@bg3 = Micronaut::Behaviour.describe(Bar, "find group-3", options_3) { }
|
26
|
+
@behaviours = [@bg1, @bg2, @bg3]
|
26
27
|
end
|
27
28
|
|
28
29
|
after(:all) do
|
29
|
-
Micronaut::World.
|
30
|
-
Micronaut::World.
|
31
|
-
Micronaut::World.
|
30
|
+
Micronaut::World.behaviours.delete(@bg1)
|
31
|
+
Micronaut::World.behaviours.delete(@bg2)
|
32
|
+
Micronaut::World.behaviours.delete(@bg3)
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should find no groups when given no search parameters" do
|
35
|
-
Micronaut::World.find.should == []
|
36
|
+
Micronaut::World.find([]).should == []
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should find three groups when searching for :described_type => Bar" do
|
39
|
-
Micronaut::World.find(:described_type => Bar).should == [@bg1, @bg2, @bg3]
|
40
|
+
Micronaut::World.find(@behaviours, :described_type => Bar).should == [@bg1, @bg2, @bg3]
|
40
41
|
end
|
41
42
|
|
42
43
|
it "should find one group when searching for :description => 'find group-1'" do
|
43
|
-
Micronaut::World.find(:description => 'find group-1').should == [@bg1]
|
44
|
+
Micronaut::World.find(@behaviours, :description => 'find group-1').should == [@bg1]
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should find two groups when searching for :description => lambda { |v| v.include?('-1') || v.include?('-3') }" do
|
47
|
-
Micronaut::World.find(:description => lambda { |v| v.include?('-1') || v.include?('-3') }).should == [@bg1, @bg3]
|
48
|
+
Micronaut::World.find(@behaviours, :description => lambda { |v| v.include?('-1') || v.include?('-3') }).should == [@bg1, @bg3]
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should find three groups when searching for :description => /find group/" do
|
51
|
-
Micronaut::World.find(:description => /find group/).should == [@bg1, @bg2, @bg3]
|
52
|
+
Micronaut::World.find(@behaviours, :description => /find group/).should == [@bg1, @bg2, @bg3]
|
52
53
|
end
|
53
54
|
|
54
55
|
it "should find one group when searching for :options => { :foo => 1 }" do
|
55
|
-
Micronaut::World.find(:options => { :foo => 1 }).should == [@bg1]
|
56
|
+
Micronaut::World.find(@behaviours, :options => { :foo => 1 }).should == [@bg1]
|
56
57
|
end
|
57
58
|
|
58
59
|
it "should find one group when searching for :options => { :pending => true }" do
|
59
|
-
Micronaut::World.find(:options => { :pending => true }).should == [@bg2]
|
60
|
+
Micronaut::World.find(@behaviours, :options => { :pending => true }).should == [@bg2]
|
60
61
|
end
|
61
62
|
|
62
63
|
it "should find one group when searching for :options => { :array => [1,2,3,4] }" do
|
63
|
-
Micronaut::World.find(:options => { :array => [1,2,3,4] }).should == [@bg3]
|
64
|
+
Micronaut::World.find(@behaviours, :options => { :array => [1,2,3,4] }).should == [@bg3]
|
64
65
|
end
|
65
66
|
|
66
67
|
it "should find no group when searching for :options => { :array => [4,3,2,1] }" do
|
67
|
-
Micronaut::World.find(:options => { :array => [4,3,2,1] }).should be_empty
|
68
|
+
Micronaut::World.find(@behaviours, :options => { :array => [4,3,2,1] }).should be_empty
|
68
69
|
end
|
69
70
|
|
70
71
|
it "should find two groups when searching for :options => { :color => 'blue' }" do
|
71
|
-
Micronaut::World.find(:options => { :color => 'blue' }).should == [@bg1, @bg3]
|
72
|
+
Micronaut::World.find(@behaviours, :options => { :color => 'blue' }).should == [@bg1, @bg3]
|
72
73
|
end
|
73
74
|
|
74
75
|
it "should find two groups when searching for :options => { :feature => 'reporting' }" do
|
75
|
-
Micronaut::World.find(:options => { :feature => 'reporting' }).should == [@bg1, @bg2]
|
76
|
+
Micronaut::World.find(@behaviours, :options => { :feature => 'reporting' }).should == [@bg1, @bg2]
|
76
77
|
end
|
77
78
|
|
78
79
|
end
|
@@ -80,13 +81,13 @@ describe Micronaut::World do
|
|
80
81
|
describe "reset" do
|
81
82
|
|
82
83
|
it "should clear the list of behaviour groups" do
|
83
|
-
original_groups = Micronaut::World.
|
84
|
+
original_groups = Micronaut::World.behaviours
|
84
85
|
|
85
|
-
Micronaut::World.
|
86
|
+
Micronaut::World.behaviours.should_not be_empty
|
86
87
|
Micronaut::World.reset
|
87
|
-
Micronaut::World.
|
88
|
+
Micronaut::World.behaviours.should be_empty
|
88
89
|
|
89
|
-
Micronaut::World.
|
90
|
+
Micronaut::World.behaviours.concat(original_groups)
|
90
91
|
end
|
91
92
|
|
92
93
|
end
|
data/lib/autotest/micronaut.rb
CHANGED
data/lib/micronaut/behaviour.rb
CHANGED
@@ -4,7 +4,7 @@ module Micronaut
|
|
4
4
|
|
5
5
|
def self.inherited(klass)
|
6
6
|
super
|
7
|
-
Micronaut::World.
|
7
|
+
Micronaut::World.behaviours << klass
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.extended_modules #:nodoc:
|
@@ -47,10 +47,18 @@ module Micronaut
|
|
47
47
|
def self.it(desc=nil, options={}, &block)
|
48
48
|
examples << Micronaut::Example.new(self, desc, options, block)
|
49
49
|
end
|
50
|
+
|
51
|
+
def self.focused(desc=nil, options={}, &block)
|
52
|
+
it(desc, options.update(:focused => true), &block)
|
53
|
+
end
|
50
54
|
|
51
55
|
def self.examples
|
52
56
|
@_examples ||= []
|
53
57
|
end
|
58
|
+
|
59
|
+
def self.examples_to_run
|
60
|
+
@_examples_to_run ||= []
|
61
|
+
end
|
54
62
|
|
55
63
|
def self.set_it_up(*args)
|
56
64
|
metadata[:options] = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -148,7 +156,7 @@ module Micronaut
|
|
148
156
|
end
|
149
157
|
|
150
158
|
def self.run(reporter)
|
151
|
-
return true if
|
159
|
+
return true if examples_to_run.empty?
|
152
160
|
|
153
161
|
reporter.add_behaviour(self)
|
154
162
|
|
@@ -156,7 +164,7 @@ module Micronaut
|
|
156
164
|
eval_before_alls(group)
|
157
165
|
success = true
|
158
166
|
|
159
|
-
|
167
|
+
examples_to_run.each do |ex|
|
160
168
|
reporter.example_started(ex)
|
161
169
|
|
162
170
|
execution_error = nil
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Micronaut
|
2
2
|
|
3
3
|
class Configuration
|
4
|
-
attr_reader :mock_framework, :backtrace_clean_patterns
|
4
|
+
attr_reader :mock_framework, :backtrace_clean_patterns, :behaviour_filters
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/]
|
@@ -68,6 +68,14 @@ module Micronaut
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def filters
|
72
|
+
@filters ||= []
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_filter(options={})
|
76
|
+
filters << options
|
77
|
+
end
|
78
|
+
|
71
79
|
def before_and_afters
|
72
80
|
@before_and_afters ||= []
|
73
81
|
end
|
data/lib/micronaut/example.rb
CHANGED
@@ -8,6 +8,13 @@ module Micronaut
|
|
8
8
|
@behaviour, @description, @options, @example_block = behaviour, desc, options, example_block
|
9
9
|
end
|
10
10
|
|
11
|
+
def metadata
|
12
|
+
@metadata ||= behaviour.metadata.dup
|
13
|
+
@metadata[:description] = description
|
14
|
+
@metadata[:options].update(options)
|
15
|
+
@metadata
|
16
|
+
end
|
17
|
+
|
11
18
|
def inspect
|
12
19
|
"#{behaviour.name} - #{description}"
|
13
20
|
end
|
data/lib/micronaut/runner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Micronaut
|
2
2
|
|
3
3
|
class Runner
|
4
|
-
|
4
|
+
|
5
5
|
def self.installed_at_exit?
|
6
6
|
@installed_at_exit ||= false
|
7
7
|
end
|
@@ -10,38 +10,41 @@ module Micronaut
|
|
10
10
|
at_exit { Micronaut::Runner.new.run(ARGV) ? exit(0) : exit(1) } unless installed_at_exit?
|
11
11
|
@installed_at_exit = true
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def options
|
15
15
|
Micronaut.configuration.options
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def run(args = [])
|
19
|
-
|
19
|
+
args.inject([]) { |files, arg| files.concat(Dir[arg].map { |g| Dir.glob(g) }.flatten) }.each do |file|
|
20
|
+
load file
|
21
|
+
end
|
22
|
+
|
23
|
+
behaviours_to_run = Micronaut::World.behaviours_to_run
|
24
|
+
total_behaviours = behaviours_to_run.inject(0) { |sum, b| sum + b.examples_to_run.size }
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
old_sync, options.formatter.output.sync = options.formatter.output.sync, true if options.formatter.output.respond_to?(:sync=)
|
24
|
-
|
25
|
-
options.formatter.start(total_examples)
|
26
|
+
old_sync, options.formatter.output.sync = options.formatter.output.sync, true if options.formatter.output.respond_to?(:sync=)
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
28
|
+
options.formatter.start(total_behaviours)
|
29
|
+
|
30
|
+
suite_success = true
|
31
|
+
|
32
|
+
starts_at = Time.now
|
33
|
+
behaviours_to_run.each do |behaviour|
|
34
|
+
suite_success &= behaviour.run(options.formatter)
|
35
|
+
end
|
36
|
+
duration = Time.now - starts_at
|
37
|
+
|
38
|
+
options.formatter.start_dump
|
39
|
+
options.formatter.dump_pending
|
40
|
+
options.formatter.dump_failures
|
41
|
+
options.formatter.dump_summary(duration, total_behaviours, options.formatter.failed_examples.size, options.formatter.pending_examples.size)
|
42
|
+
|
43
|
+
options.formatter.output.sync = old_sync if options.formatter.output.respond_to? :sync=
|
44
|
+
|
45
|
+
suite_success
|
43
46
|
end
|
44
|
-
|
47
|
+
|
45
48
|
end
|
46
|
-
|
49
|
+
|
47
50
|
end
|
data/lib/micronaut/world.rb
CHANGED
@@ -1,36 +1,53 @@
|
|
1
1
|
module Micronaut
|
2
2
|
|
3
3
|
class World
|
4
|
-
|
4
|
+
|
5
5
|
def self.reset
|
6
|
-
@
|
6
|
+
@behaviours = []
|
7
7
|
end
|
8
8
|
|
9
9
|
reset
|
10
|
-
|
11
|
-
def self.
|
12
|
-
@
|
10
|
+
|
11
|
+
def self.behaviours
|
12
|
+
@behaviours
|
13
13
|
end
|
14
|
-
|
15
|
-
def self.
|
16
|
-
|
14
|
+
|
15
|
+
def self.behaviours_to_run
|
16
|
+
Micronaut.configuration.filters.each do |filter|
|
17
|
+
puts " Run filtered using: #{filter.inspect}"
|
18
|
+
behaviours.each do |behaviour|
|
19
|
+
behaviour.examples_to_run.concat find(behaviour.examples, filter)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# if behaviours.inject(0) { |sum, b| sum += b.examples_to_run.size }.zero?
|
24
|
+
# behaviours.each do |behaviour|
|
25
|
+
# behaviour.examples_to_run.concat(behaviour.examples)
|
26
|
+
# end
|
27
|
+
# end
|
17
28
|
|
18
|
-
|
29
|
+
behaviours
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.find(collection, conditions={})
|
33
|
+
return [] if conditions.empty?
|
34
|
+
|
35
|
+
collection.select do |item|
|
19
36
|
conditions.all? do |key, value|
|
20
37
|
case value
|
21
38
|
when Hash
|
22
|
-
value.all? { |k, v|
|
39
|
+
value.all? { |k, v| item.metadata[key][k] == v }
|
23
40
|
when Regexp
|
24
|
-
|
41
|
+
item.metadata[key] =~ value
|
25
42
|
when Proc
|
26
|
-
value.call(
|
43
|
+
value.call(item.metadata[key]) rescue false
|
27
44
|
else
|
28
|
-
|
45
|
+
item.metadata[key] == value
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
32
49
|
end
|
33
|
-
|
50
|
+
|
34
51
|
end
|
35
|
-
|
52
|
+
|
36
53
|
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Humphries
|
@@ -9,14 +9,14 @@ autorequire: micronaut
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
13
|
-
default_executable:
|
12
|
+
date: 2008-12-12 00:00:00 -08:00
|
13
|
+
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: An excellent replacement for the wheel...
|
17
17
|
email: chad@spicycode.com
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- micronaut
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- examples/lib/micronaut_example.rb
|
120
120
|
- examples/resources
|
121
121
|
- examples/resources/example_classes.rb
|
122
|
+
- bin/micronaut
|
122
123
|
has_rdoc: true
|
123
124
|
homepage: http://spicycode.com
|
124
125
|
post_install_message:
|