micronaut 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -18
- data/VERSION.yml +2 -2
- data/examples/lib/micronaut/configuration_example.rb +10 -0
- data/examples/lib/micronaut/world_example.rb +91 -22
- data/lib/micronaut/configuration.rb +3 -1
- data/lib/micronaut/formatters/base_formatter.rb +2 -2
- data/lib/micronaut/mocking/with_mocha.rb +6 -1
- data/lib/micronaut/world.rb +30 -9
- metadata +3 -4
- data/History.txt +0 -15
data/Rakefile
CHANGED
@@ -23,24 +23,8 @@ end
|
|
23
23
|
begin
|
24
24
|
require 'rake/contrib/sshpublisher'
|
25
25
|
namespace :rubyforge do
|
26
|
-
|
27
26
|
desc "Release gem and RDoc documentation to RubyForge"
|
28
|
-
task :release => ["rubyforge:release:gem"
|
29
|
-
|
30
|
-
namespace :release do
|
31
|
-
desc "Publish RDoc to RubyForge."
|
32
|
-
task :docs => [:rdoc] do
|
33
|
-
config = YAML.load(
|
34
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
35
|
-
)
|
36
|
-
|
37
|
-
host = "#{config['username']}@rubyforge.org"
|
38
|
-
remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
|
39
|
-
local_dir = 'rdoc'
|
40
|
-
|
41
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
42
|
-
end
|
43
|
-
end
|
27
|
+
task :release => ["rubyforge:release:gem"]
|
44
28
|
end
|
45
29
|
rescue LoadError
|
46
30
|
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
@@ -58,7 +42,7 @@ task :untested do
|
|
58
42
|
end
|
59
43
|
end
|
60
44
|
|
61
|
-
puts "Running in Ruby #{RUBY_VERSION}"
|
45
|
+
puts "Running in Ruby #{RUBY_PLATFORM} #{RUBY_VERSION}"
|
62
46
|
desc "Run all micronaut examples"
|
63
47
|
Micronaut::RakeTask.new :examples do |t|
|
64
48
|
t.pattern = "examples/**/*_example.rb"
|
data/VERSION.yml
CHANGED
@@ -11,16 +11,16 @@ describe Micronaut::World do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "behaviour groups" do
|
14
|
-
|
14
|
+
|
15
15
|
it "should contain all defined behaviour groups" do
|
16
16
|
behaviour_group = Micronaut::Behaviour.describe(Bar, 'Empty Behaviour Group') { }
|
17
17
|
@world.behaviours.should include(behaviour_group)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
end
|
21
|
-
|
22
|
-
describe "
|
23
|
-
|
21
|
+
|
22
|
+
describe "applying inclusion filters" do
|
23
|
+
|
24
24
|
before(:all) do
|
25
25
|
options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
|
26
26
|
options_2 = { :pending => true, :feature => 'reporting' }
|
@@ -44,55 +44,124 @@ describe Micronaut::World do
|
|
44
44
|
Micronaut.world.behaviours.delete(@bg3)
|
45
45
|
Micronaut.world.behaviours.delete(@bg4)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should find awesome examples" do
|
49
|
-
@world.
|
49
|
+
@world.apply_inclusion_filters(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should find no groups when given no search parameters" do
|
53
|
-
@world.
|
53
|
+
@world.apply_inclusion_filters([]).should == []
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should find three groups when searching for :behaviour_describes => Bar" do
|
57
|
-
@world.
|
57
|
+
@world.apply_inclusion_filters(@behaviours, :behaviour => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should find one group when searching for :description => 'find group-1'" do
|
61
|
-
@world.
|
61
|
+
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should find two groups when searching for :description => lambda { |v| v.include?('-1') || v.include?('-3') }" do
|
65
|
-
@world.
|
65
|
+
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should find three groups when searching for :description => /find group/" do
|
69
|
-
@world.
|
69
|
+
@world.apply_inclusion_filters(@behaviours, :behaviour => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should find one group when searching for :foo => 1" do
|
73
|
-
@world.
|
73
|
+
@world.apply_inclusion_filters(@behaviours, :foo => 1 ).should == [@bg1]
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should find one group when searching for :pending => true" do
|
77
|
-
@world.
|
77
|
+
@world.apply_inclusion_filters(@behaviours, :pending => true ).should == [@bg2]
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
it "should find one group when searching for :array => [1,2,3,4]" do
|
81
|
-
@world.
|
81
|
+
@world.apply_inclusion_filters(@behaviours, :array => [1,2,3,4]).should == [@bg3]
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "should find no group when searching for :array => [4,3,2,1]" do
|
85
|
-
@world.
|
85
|
+
@world.apply_inclusion_filters(@behaviours, :array => [4,3,2,1]).should be_empty
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "should find two groups when searching for :color => 'blue'" do
|
89
|
-
@world.
|
89
|
+
@world.apply_inclusion_filters(@behaviours, :color => 'blue').should == [@bg1, @bg3]
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
it "should find two groups when searching for :feature => 'reporting' }" do
|
93
|
-
@world.
|
93
|
+
@world.apply_inclusion_filters(@behaviours, :feature => 'reporting').should == [@bg1, @bg2]
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "applying exclusion filters" do
|
99
|
+
|
100
|
+
it "should find nothing if all describes match the exclusion filter" do
|
101
|
+
options = { :network_access => true }
|
102
|
+
|
103
|
+
isolate_behaviour do
|
104
|
+
group1 = Micronaut::Behaviour.describe(Bar, "find group-1", options) do
|
105
|
+
it("foo") {}
|
106
|
+
it("bar") {}
|
107
|
+
end
|
108
|
+
|
109
|
+
@world.apply_exclusion_filters(group1.examples, :network_access => true).should == []
|
110
|
+
end
|
111
|
+
|
112
|
+
isolate_behaviour do
|
113
|
+
group2 = Micronaut::Behaviour.describe(Bar, "find group-1") do
|
114
|
+
it("foo", :network_access => true) {}
|
115
|
+
it("bar") {}
|
116
|
+
end
|
117
|
+
|
118
|
+
@world.apply_exclusion_filters(group2.examples, :network_access => true).should == [group2.examples.last]
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should find nothing if a regexp matches the exclusion filter" do
|
124
|
+
isolate_behaviour do
|
125
|
+
group = Micronaut::Behaviour.describe(Bar, "find group-1", :name => "exclude me with a regex", :another => "foo") do
|
126
|
+
it("foo") {}
|
127
|
+
it("bar") {}
|
128
|
+
end
|
129
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/).should == []
|
130
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should == []
|
131
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :behaviour => {
|
132
|
+
:describes => lambda { |b| b == Bar } } ).should == []
|
133
|
+
|
134
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude not/).should == group.examples
|
135
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo").should == group.examples
|
136
|
+
@world.apply_exclusion_filters(group.examples, :name => /exclude/, "another_condition" => "foo1").should == group.examples
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "filtering behaviours" do
|
143
|
+
|
144
|
+
before(:all) do
|
145
|
+
@group1 = Micronaut::Behaviour.describe(Bar, "find these examples") do
|
146
|
+
it('I have no options', :color => :red, :awesome => true) {}
|
147
|
+
it("I also have no options", :color => :red, :awesome => true) {}
|
148
|
+
it("not so awesome", :color => :red, :awesome => false) {}
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
after(:all) do
|
153
|
+
Micronaut.world.behaviours.delete(@group1)
|
94
154
|
end
|
95
155
|
|
156
|
+
it "should run matches" do
|
157
|
+
Micronaut.world.stubs(:exclusion_filter).returns({ :awesome => false })
|
158
|
+
Micronaut.world.stubs(:filter).returns({ :color => :red })
|
159
|
+
Micronaut.world.stubs(:behaviours).returns([@group1])
|
160
|
+
filtered_behaviours = @world.filter_behaviours
|
161
|
+
filtered_behaviours.should == [@group1]
|
162
|
+
@group1.examples_to_run.should == @group1.examples[0..1]
|
163
|
+
end
|
164
|
+
|
96
165
|
end
|
97
166
|
|
98
167
|
end
|
@@ -10,6 +10,8 @@ module Micronaut
|
|
10
10
|
# Allows you to control what examples are ran by filtering
|
11
11
|
attr_reader :filter
|
12
12
|
|
13
|
+
attr_reader :exclusion_filter
|
14
|
+
|
13
15
|
# Modules that will be included or extended based on given filters
|
14
16
|
attr_reader :include_or_extend_modules
|
15
17
|
|
@@ -34,7 +36,7 @@ module Micronaut
|
|
34
36
|
@before_and_afters = { :before => { :each => [], :all => [] }, :after => { :each => [], :all => [] } }
|
35
37
|
@include_or_extend_modules = []
|
36
38
|
@formatter_to_use = Micronaut::Formatters::ProgressFormatter
|
37
|
-
@filter = nil
|
39
|
+
@filter, @exclusion_filter = nil, nil
|
38
40
|
mock_with nil unless @mock_framework_established
|
39
41
|
end
|
40
42
|
|
@@ -37,11 +37,11 @@ module Micronaut
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def pending_examples
|
40
|
-
@pending_examples ||= ::Micronaut.world.find(examples, :execution_result => { :status => 'pending' })
|
40
|
+
@pending_examples ||= ::Micronaut.world.find(examples, :positive, :execution_result => { :status => 'pending' })
|
41
41
|
end
|
42
42
|
|
43
43
|
def failed_examples
|
44
|
-
@failed_examples ||= ::Micronaut.world.find(examples, :execution_result => { :status => 'failed' })
|
44
|
+
@failed_examples ||= ::Micronaut.world.find(examples, :positive, :execution_result => { :status => 'failed' })
|
45
45
|
end
|
46
46
|
|
47
47
|
# This method is invoked before any examples are run, right after
|
@@ -4,7 +4,12 @@ require 'mocha/object'
|
|
4
4
|
module Micronaut
|
5
5
|
module Mocking
|
6
6
|
module WithMocha
|
7
|
-
|
7
|
+
# Mocha::Standalone was deprecated as of Mocha 0.9.7.
|
8
|
+
begin
|
9
|
+
include Mocha::API
|
10
|
+
rescue NameError
|
11
|
+
include Mocha::Standalone
|
12
|
+
end
|
8
13
|
|
9
14
|
alias :_setup_mocks :mocha_setup
|
10
15
|
alias :_verify_mocks :mocha_verify
|
data/lib/micronaut/world.rb
CHANGED
@@ -11,11 +11,15 @@ module Micronaut
|
|
11
11
|
def filter
|
12
12
|
Micronaut.configuration.filter
|
13
13
|
end
|
14
|
+
|
15
|
+
def exclusion_filter
|
16
|
+
Micronaut.configuration.exclusion_filter
|
17
|
+
end
|
14
18
|
|
15
19
|
def behaviours_to_run
|
16
20
|
return @behaviours_to_run if @behaviours_to_run
|
17
21
|
|
18
|
-
if filter
|
22
|
+
if filter || exclusion_filter
|
19
23
|
@behaviours_to_run = filter_behaviours
|
20
24
|
if @behaviours_to_run.size == 0 && Micronaut.configuration.run_all_when_everything_filtered?
|
21
25
|
puts "No examples were matched by #{filter.inspect}, running all"
|
@@ -38,21 +42,38 @@ module Micronaut
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def filter_behaviours
|
41
|
-
behaviours.inject([]) do |
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
behaviours.inject([]) do |list_of_behaviors, _behavior|
|
46
|
+
examples = _behavior.examples
|
47
|
+
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
|
48
|
+
examples = apply_inclusion_filters(examples, filter) if filter
|
49
|
+
examples.uniq!
|
50
|
+
_behavior.examples_to_run.replace(examples)
|
51
|
+
if examples.empty?
|
52
|
+
list_of_behaviors << nil
|
53
|
+
else
|
54
|
+
list_of_behaviors << _behavior
|
55
|
+
end
|
45
56
|
end.compact
|
46
57
|
end
|
47
58
|
|
48
|
-
def find(collection, conditions={})
|
59
|
+
def find(collection, type_of_filter=:positive, conditions={})
|
60
|
+
negative = type_of_filter != :positive
|
61
|
+
|
49
62
|
collection.select do |item|
|
50
|
-
conditions.
|
63
|
+
# negative conditions.any?, positive conditions.all? ?????
|
64
|
+
result = conditions.all? do |filter_on, filter|
|
65
|
+
apply_condition(filter_on, filter, item.metadata)
|
66
|
+
end
|
67
|
+
negative ? !result : result
|
51
68
|
end
|
52
69
|
end
|
53
70
|
|
54
|
-
def
|
55
|
-
find(
|
71
|
+
def apply_inclusion_filters(collection, conditions={})
|
72
|
+
find(collection, :positive, conditions)
|
73
|
+
end
|
74
|
+
|
75
|
+
def apply_exclusion_filters(collection, conditions={})
|
76
|
+
find(collection, :negative, conditions)
|
56
77
|
end
|
57
78
|
|
58
79
|
def apply_condition(filter_on, filter, metadata)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micronaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-
|
12
|
+
date: 2009-08-10 00:00:00 -04:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,7 +23,6 @@ extra_rdoc_files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.markdown
|
25
25
|
files:
|
26
|
-
- History.txt
|
27
26
|
- LICENSE
|
28
27
|
- README.markdown
|
29
28
|
- RSPEC-LICENSE
|
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
124
|
requirements: []
|
126
125
|
|
127
126
|
rubyforge_project: spicycode-depot
|
128
|
-
rubygems_version: 1.3.
|
127
|
+
rubygems_version: 1.3.5
|
129
128
|
signing_key:
|
130
129
|
specification_version: 3
|
131
130
|
summary: An excellent replacement for the wheel...
|
data/History.txt
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
0.0.8
|
2
|
-
=======================
|
3
|
-
- It turns out I'm horrible at updating history files
|
4
|
-
- Added MockWith::AbsolutelyNothing as the default
|
5
|
-
- Added the ability to setup before, after, include, and extend blocks using a extensible API
|
6
|
-
|
7
|
-
0.0.6
|
8
|
-
=======================
|
9
|
-
- MockWith::Mocha autoloads now
|
10
|
-
- Beginnings of the configure block in example helper
|
11
|
-
- Ability to search behaviour groups is in
|
12
|
-
|
13
|
-
0.0.5
|
14
|
-
=======================
|
15
|
-
- Describes are working at any level, befores/afters correctly cascade
|