spicycode-micronaut 0.1.7 → 0.1.7.1
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 +1 -1
- data/examples/example_helper.rb +5 -18
- data/examples/lib/micronaut/behaviour_example.rb +12 -14
- data/examples/lib/micronaut/configuration_example.rb +7 -6
- data/examples/lib/micronaut/example_example.rb +1 -1
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +11 -11
- data/lib/micronaut/behaviour.rb +16 -24
- data/lib/micronaut/configuration.rb +60 -61
- data/lib/micronaut/example.rb +1 -1
- data/lib/micronaut/formatters/base_formatter.rb +6 -9
- data/lib/micronaut/formatters/base_text_formatter.rb +2 -2
- data/lib/micronaut/runner.rb +3 -2
- data/lib/micronaut/world.rb +9 -9
- data/lib/micronaut.rb +2 -1
- metadata +1 -2
- data/lib/micronaut/mocking.rb +0 -7
data/Rakefile
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -23,21 +23,8 @@ def remove_last_describe_from_world
|
|
23
23
|
Micronaut.world.behaviours.pop
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def use_color?
|
33
|
-
!ENV.has_key?('TM_MODE')
|
34
|
-
end
|
35
|
-
|
36
|
-
Micronaut.configure do |config|
|
37
|
-
config.mock_with :mocha
|
38
|
-
config.color_enabled = use_color?
|
39
|
-
config.formatter = :documentation
|
40
|
-
config.profile_examples = false
|
41
|
-
config.filter_run :focused => true
|
42
|
-
config.autorun!
|
43
|
-
end
|
26
|
+
Micronaut.configure do |c|
|
27
|
+
c.mock_with :mocha
|
28
|
+
c.color_enabled = !ENV.has_key?('TM_MODE')
|
29
|
+
c.filter_run :focused => true
|
30
|
+
end
|
@@ -9,7 +9,7 @@ describe Micronaut::Behaviour do
|
|
9
9
|
|
10
10
|
describe "describing behaviour with #describe" do
|
11
11
|
|
12
|
-
example "an ArgumentError is raised if no
|
12
|
+
example "an ArgumentError is raised if no type or description is given" do
|
13
13
|
lambda { Micronaut::Behaviour.describe() {} }.should raise_error(ArgumentError, "No arguments given. You must a least supply a type or description")
|
14
14
|
end
|
15
15
|
|
@@ -59,29 +59,27 @@ describe Micronaut::Behaviour do
|
|
59
59
|
Micronaut::Behaviour.describe(Object, nil, 'foo' => 'bar') { }.metadata.should include({ "foo" => 'bar' })
|
60
60
|
end
|
61
61
|
|
62
|
-
it "should add the
|
63
|
-
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:
|
62
|
+
it "should add the caller to metadata" do
|
63
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:caller].should == "#{__FILE__}:#{__LINE__}"
|
64
64
|
end
|
65
65
|
|
66
|
-
it "should add the the file_path
|
67
|
-
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path].should ==
|
66
|
+
it "should add the the file_path to metadata" do
|
67
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path].should == __FILE__
|
68
68
|
end
|
69
69
|
|
70
|
-
it "should
|
71
|
-
Micronaut::Behaviour.describe(Object) { }.file_path.should ==
|
70
|
+
it "should have a reader for file_path" do
|
71
|
+
Micronaut::Behaviour.describe(Object) { }.file_path.should == __FILE__
|
72
72
|
end
|
73
73
|
|
74
|
-
it "should add the line_number
|
74
|
+
it "should add the line_number to metadata" do
|
75
75
|
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should add file path and line number metadata for arbitrarily nested describes" do
|
79
79
|
Micronaut::Behaviour.describe(Object) do
|
80
80
|
Micronaut::Behaviour.describe("foo") do
|
81
|
-
|
82
|
-
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:file_path_with_line_number].should == "#{__FILE__}:#{__LINE__}"
|
81
|
+
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:caller].should == "#{__FILE__}:#{__LINE__}"
|
83
82
|
Micronaut::Behaviour.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
|
84
|
-
|
85
83
|
end
|
86
84
|
end
|
87
85
|
end
|
@@ -211,10 +209,10 @@ describe Micronaut::Behaviour do
|
|
211
209
|
end
|
212
210
|
|
213
211
|
describe "#run" do
|
212
|
+
|
213
|
+
pending "should run after(:each) when the example fails"
|
214
214
|
|
215
|
-
pending "should run after(:each)
|
216
|
-
|
217
|
-
pending "should run after(:each) even if the example raises an Exception"
|
215
|
+
pending "should run after(:each) when the example raises an Exception"
|
218
216
|
|
219
217
|
end
|
220
218
|
|
@@ -25,9 +25,9 @@ describe Micronaut::Configuration do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should include the given module into each behaviour
|
29
|
-
Micronaut.configuration.include(InstanceLevelMethods)
|
30
|
-
group = Micronaut::Behaviour.describe(Object, 'does like, stuff and junk') { }
|
28
|
+
it "should include the given module into each matching behaviour" do
|
29
|
+
Micronaut.configuration.include(InstanceLevelMethods, :magic_key => :include)
|
30
|
+
group = Micronaut::Behaviour.describe(Object, 'does like, stuff and junk', :magic_key => :include) { }
|
31
31
|
group.should_not respond_to(:you_call_this_a_blt?)
|
32
32
|
remove_last_describe_from_world
|
33
33
|
|
@@ -45,9 +45,10 @@ describe Micronaut::Configuration do
|
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should extend the given module into each behaviour
|
49
|
-
Micronaut.configuration.extend(ThatThingISentYou)
|
50
|
-
group = Micronaut::Behaviour.describe(ThatThingISentYou) { }
|
48
|
+
it "should extend the given module into each matching behaviour" do
|
49
|
+
Micronaut.configuration.extend(ThatThingISentYou, :magic_key => :extend)
|
50
|
+
group = Micronaut::Behaviour.describe(ThatThingISentYou, :magic_key => :extend) { }
|
51
|
+
|
51
52
|
group.should respond_to(:that_thing)
|
52
53
|
remove_last_describe_from_world
|
53
54
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
|
3
3
|
describe Micronaut::Example do
|
4
4
|
|
5
5
|
before do
|
6
|
-
behaviour = stub('behaviour', :
|
6
|
+
behaviour = stub('behaviour', :metadata => { :behaviour => { :name => 'behaviour_name' }})
|
7
7
|
@example = Micronaut::Example.new(behaviour, 'description', {}, (lambda {}))
|
8
8
|
end
|
9
9
|
|
@@ -104,20 +104,20 @@ describe Micronaut::Formatters::BaseFormatter do
|
|
104
104
|
@formatter.should have_interface_for(:close).with(0).arguments
|
105
105
|
end
|
106
106
|
|
107
|
-
describe '
|
107
|
+
describe '#format_backtrace' do
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
before do
|
110
|
+
@full_backtrace = ["examples/lib/micronaut/formatters/base_formatter_example.rb:118", "vendor/rails/x.rb:1", "/bin/micronaut"]
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should display the full backtrace when the example is given the :full_backtrace => true option", :full_backtrace => true do
|
114
|
+
running_example.metadata[:full_backtrace].should be_true
|
115
|
+
@formatter.format_backtrace(@full_backtrace, running_example).should == @full_backtrace
|
113
116
|
end
|
114
|
-
|
115
|
-
it "should ensure ':' in the first backtrace" do
|
116
|
-
backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
117
|
-
@formatter.format_backtrace(backtrace, running_example).should == backtrace
|
118
117
|
|
119
|
-
|
120
|
-
|
118
|
+
it "should clean the backtrace when the full_backtrace option is not given" do
|
119
|
+
running_example.metadata[:full_backtrace].should be_nil
|
120
|
+
@formatter.format_backtrace(@full_backtrace, running_example).should == ["examples/lib/micronaut/formatters/base_formatter_example.rb:118"]
|
121
121
|
end
|
122
122
|
|
123
123
|
end
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -75,36 +75,28 @@ module Micronaut
|
|
75
75
|
@_examples_to_run ||= []
|
76
76
|
end
|
77
77
|
|
78
|
-
# This method is friggin' gigantic, and must be stopped
|
79
|
-
#
|
80
78
|
def self.set_it_up(*args)
|
81
|
-
@metadata = {:behaviour => {}}
|
79
|
+
@metadata = { :behaviour => {} }
|
82
80
|
extra_metadata = args.last.is_a?(Hash) ? args.pop : {}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
81
|
+
extra_metadata.delete(:behaviour) # Remove it when present to prevent it clobbering the one we setup
|
82
|
+
|
83
|
+
@metadata[:behaviour][:describes] = args.shift unless args.first.is_a?(String)
|
84
|
+
@metadata[:behaviour][:describes] ||= self.superclass.metadata && self.superclass.metadata[:behaviour][:describes]
|
88
85
|
@metadata[:behaviour][:description] = args.shift || ''
|
89
86
|
@metadata[:behaviour][:name] = "#{describes} #{description}".strip
|
90
87
|
@metadata[:behaviour][:block] = extra_metadata.delete(:behaviour_block)
|
91
|
-
|
92
|
-
@metadata[:behaviour][:
|
93
|
-
@metadata[:behaviour][:
|
94
|
-
@metadata[:behaviour][:line_number] = file_path_with_line_num.split(":")[1].to_i
|
88
|
+
@metadata[:behaviour][:caller] = eval("caller(0)[0]", @metadata[:behaviour][:block].binding)
|
89
|
+
@metadata[:behaviour][:file_path] = @metadata[:behaviour][:caller].split(":")[0].strip
|
90
|
+
@metadata[:behaviour][:line_number] = @metadata[:behaviour][:caller].split(":")[1].to_i
|
95
91
|
|
96
|
-
extra_metadata.delete(:behaviour) # Remove it if it is present
|
97
92
|
@metadata.update(extra_metadata)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
else
|
106
|
-
send(:include, mod) unless included_modules.include?(mod)
|
107
|
-
end
|
93
|
+
|
94
|
+
Micronaut.configuration.find_modules(self).each do |include_or_extend, mod, opts|
|
95
|
+
if include_or_extend == :extend
|
96
|
+
send(:extend, mod) unless extended_modules.include?(mod)
|
97
|
+
else
|
98
|
+
send(:include, mod) unless included_modules.include?(mod)
|
99
|
+
end
|
108
100
|
end
|
109
101
|
end
|
110
102
|
|
@@ -245,7 +237,7 @@ module Micronaut
|
|
245
237
|
end
|
246
238
|
|
247
239
|
def self.to_s
|
248
|
-
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' : name
|
240
|
+
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' : @metadata[:behaviour][:name]
|
249
241
|
end
|
250
242
|
|
251
243
|
end
|
@@ -1,48 +1,46 @@
|
|
1
1
|
module Micronaut
|
2
2
|
|
3
3
|
class Configuration
|
4
|
-
#
|
5
|
-
# Currently supported: :mocha, :rr, or nothing (the default if this is not set at all)
|
6
|
-
attr_reader :mock_framework
|
7
|
-
|
8
|
-
# Array of regular expressions to scrub from backtrace
|
4
|
+
# Regex patterns to scrub backtrace with
|
9
5
|
attr_reader :backtrace_clean_patterns
|
10
6
|
|
11
|
-
#
|
7
|
+
# All of the defined before/after blocks setup in the configuration
|
12
8
|
attr_reader :before_and_afters
|
13
|
-
|
14
|
-
# Adding a filter allows you to exclude or include certain examples from running based on options you pass in
|
15
|
-
attr_reader :filter
|
16
9
|
|
17
|
-
#
|
18
|
-
|
10
|
+
# Allows you to control what examples are ran by filtering
|
11
|
+
attr_reader :filter_run
|
12
|
+
|
13
|
+
# Modules that will be included or extended based on given filters
|
14
|
+
attr_reader :include_or_extend_modules
|
15
|
+
|
16
|
+
# Run all examples if the run is filtered, and no examples were found - defaults to true
|
19
17
|
attr_accessor :run_all_when_everything_filtered
|
20
18
|
|
21
|
-
# Enable profiling of
|
19
|
+
# Enable profiling of example run - defaults to false
|
22
20
|
attr_accessor :profile_examples
|
23
|
-
|
21
|
+
|
24
22
|
def initialize
|
25
|
-
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/, /bin\/micronaut/]
|
23
|
+
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/, /bin\/micronaut/, /#{::Micronaut::InstallDirectory}/]
|
26
24
|
@profile_examples = false
|
27
25
|
@run_all_when_everything_filtered = true
|
28
|
-
@
|
29
|
-
@before_and_afters = []
|
26
|
+
@color_enabled = false
|
27
|
+
@before_and_afters = { :before => { :each => [], :all => [] }, :after => { :each => [], :all => [] } }
|
28
|
+
@include_or_extend_modules = []
|
29
|
+
@formatter_to_use = Micronaut::Formatters::ProgressFormatter
|
30
30
|
end
|
31
31
|
|
32
|
+
# E.g. alias_example_to :crazy_slow, :speed => 'crazy_slow' defines
|
33
|
+
# crazy_slow as an example variant that has the crazy_slow speed option
|
32
34
|
def alias_example_to(new_name, extra_options={})
|
33
35
|
Micronaut::Behaviour.alias_example_to(new_name, extra_options)
|
34
36
|
end
|
35
37
|
|
36
38
|
def cleaned_from_backtrace?(line)
|
37
|
-
|
38
|
-
|
39
|
-
@backtrace_clean_patterns.any? do |pattern|
|
40
|
-
line =~ pattern
|
41
|
-
end
|
39
|
+
@backtrace_clean_patterns.any? { |regex| line =~ regex }
|
42
40
|
end
|
43
41
|
|
44
42
|
def mock_with(make_a_mockery_with=nil)
|
45
|
-
|
43
|
+
mock_framework = case make_a_mockery_with
|
46
44
|
when :mocha
|
47
45
|
require 'micronaut/mocking/with_mocha'
|
48
46
|
Micronaut::Mocking::WithMocha
|
@@ -50,88 +48,89 @@ module Micronaut
|
|
50
48
|
require 'micronaut/mocking/with_rr'
|
51
49
|
Micronaut::Mocking::WithRR
|
52
50
|
else
|
51
|
+
require 'micronaut/mocking/with_absolutely_nothing'
|
53
52
|
Micronaut::Mocking::WithAbsolutelyNothing
|
54
53
|
end
|
55
54
|
|
56
|
-
Micronaut::Behaviour.send(:include,
|
55
|
+
Micronaut::Behaviour.send(:include, mock_framework)
|
57
56
|
end
|
58
57
|
|
59
58
|
def autorun!
|
60
59
|
Micronaut::Runner.autorun
|
61
60
|
end
|
61
|
+
|
62
|
+
def color_enabled=(on_or_off)
|
63
|
+
@color_enabled = on_or_off
|
64
|
+
end
|
62
65
|
|
63
|
-
#
|
64
|
-
# defaults to true
|
66
|
+
# Output with ANSI color enabled? Defaults to false
|
65
67
|
def color_enabled?
|
66
68
|
@color_enabled
|
67
69
|
end
|
68
70
|
|
69
|
-
def
|
70
|
-
@
|
71
|
+
def filter_run(options={})
|
72
|
+
@filter_run = options
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_all_when_everything_filtered?
|
76
|
+
@run_all_when_everything_filtered
|
71
77
|
end
|
72
78
|
|
73
|
-
# The formatter to use. Defaults to the documentation formatter
|
74
79
|
def formatter=(formatter_to_use)
|
75
|
-
@formatter_to_use = formatter_to_use.to_s
|
80
|
+
@formatter_to_use = case formatter_to_use.to_s
|
81
|
+
when 'documentation' then Micronaut::Formatters::DocumentationFormatter
|
82
|
+
when 'progress' then Micronaut::Formatters::ProgressFormatter
|
83
|
+
end
|
76
84
|
end
|
77
85
|
|
86
|
+
# The formatter all output should use. Defaults to the progress formatter
|
78
87
|
def formatter
|
79
|
-
@formatter ||=
|
80
|
-
when 'documentation'
|
81
|
-
Micronaut::Formatters::DocumentationFormatter.new
|
82
|
-
else
|
83
|
-
Micronaut::Formatters::ProgressFormatter.new
|
84
|
-
end
|
88
|
+
@formatter ||= @formatter_to_use.new
|
85
89
|
end
|
86
90
|
|
91
|
+
# Where does output go? For now $stdout
|
87
92
|
def output
|
88
93
|
$stdout
|
89
94
|
end
|
90
|
-
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
|
96
|
+
def include(mod, options={})
|
97
|
+
if options.empty?
|
98
|
+
Micronaut::Behaviour.send(:include, mod)
|
99
|
+
else
|
100
|
+
include_or_extend_modules << [:include, mod, options]
|
101
|
+
end
|
97
102
|
end
|
98
103
|
|
99
|
-
def extend(
|
100
|
-
|
104
|
+
def extend(mod, options={})
|
105
|
+
if options.empty?
|
106
|
+
Micronaut::Behaviour.send(:extend, mod)
|
107
|
+
else
|
108
|
+
include_or_extend_modules << [:extend, mod, options]
|
109
|
+
end
|
101
110
|
end
|
102
111
|
|
103
112
|
def find_modules(group)
|
104
|
-
|
113
|
+
include_or_extend_modules.select do |include_or_extend, mod, options|
|
105
114
|
options.all? do |filter_on, filter|
|
106
115
|
Micronaut.world.apply_condition(filter_on, filter, group.metadata)
|
107
116
|
end
|
108
117
|
end
|
109
118
|
end
|
110
|
-
|
111
|
-
def filter_run(options={})
|
112
|
-
@filter = options
|
113
|
-
end
|
114
|
-
|
115
|
-
def run_all_when_everything_filtered?
|
116
|
-
@run_all_when_everything_filtered
|
117
|
-
end
|
118
119
|
|
119
|
-
def before(
|
120
|
-
before_and_afters
|
120
|
+
def before(each_or_all=:each, options={}, &block)
|
121
|
+
before_and_afters[:before][each_or_all] << [options, block]
|
121
122
|
end
|
122
123
|
|
123
|
-
def after(
|
124
|
-
before_and_afters
|
124
|
+
def after(each_or_all=:each, options={}, &block)
|
125
|
+
before_and_afters[:after][each_or_all] << [options, block]
|
125
126
|
end
|
126
127
|
|
127
128
|
def find_before_or_after(desired_type, desired_each_or_all, group)
|
128
|
-
before_and_afters.select do |
|
129
|
-
type == desired_type &&
|
130
|
-
each_or_all == desired_each_or_all &&
|
129
|
+
before_and_afters[desired_type][desired_each_or_all].select do |options, block|
|
131
130
|
options.all? do |filter_on, filter|
|
132
131
|
Micronaut.world.apply_condition(filter_on, filter, group.metadata)
|
133
132
|
end
|
134
|
-
end.map { |
|
133
|
+
end.map { |options, block| block }
|
135
134
|
end
|
136
135
|
|
137
136
|
end
|
data/lib/micronaut/example.rb
CHANGED
@@ -105,13 +105,10 @@ module Micronaut
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def format_backtrace(backtrace, example)
|
108
|
-
return ""
|
109
|
-
|
110
|
-
|
111
|
-
cleansed = cleansed.select do |line|
|
112
|
-
line.split(':').first.downcase == example.behaviour.file_path.downcase
|
113
|
-
end
|
108
|
+
return "" unless backtrace
|
109
|
+
return backtrace if example.metadata[:full_backtrace] == true
|
114
110
|
|
111
|
+
cleansed = backtrace.select { |line| backtrace_line(line) }
|
115
112
|
cleansed.empty? ? backtrace : cleansed
|
116
113
|
end
|
117
114
|
|
@@ -126,10 +123,10 @@ module Micronaut
|
|
126
123
|
|
127
124
|
def read_failed_line(exception, example)
|
128
125
|
original_file = example.behaviour.file_path.downcase
|
129
|
-
matching_line = exception.backtrace.
|
130
|
-
|
131
|
-
end
|
126
|
+
matching_line = exception.backtrace.detect { |line| line.split(':').first.downcase == original_file.downcase }
|
127
|
+
|
132
128
|
return "Unable to find matching line from backtrace" if matching_line.nil?
|
129
|
+
|
133
130
|
file_path, line_number = matching_line.split(':')
|
134
131
|
if File.exist?(file_path)
|
135
132
|
open(file_path, 'r') { |f| f.readlines[line_number.to_i - 1] }
|
@@ -93,8 +93,8 @@ module Micronaut
|
|
93
93
|
output.puts
|
94
94
|
output.puts "Pending:"
|
95
95
|
pending_examples.each do |pending_example, message|
|
96
|
-
output.puts "
|
97
|
-
output.puts grey("
|
96
|
+
output.puts " #{pending_example}"
|
97
|
+
output.puts grey(" # #{pending_example.metadata[:caller]}")
|
98
98
|
end
|
99
99
|
end
|
100
100
|
output.flush
|
data/lib/micronaut/runner.rb
CHANGED
@@ -7,8 +7,9 @@ module Micronaut
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.autorun
|
10
|
-
|
10
|
+
return if installed_at_exit?
|
11
11
|
@installed_at_exit = true
|
12
|
+
at_exit { Micronaut::Runner.new.run(ARGV) ? exit(0) : exit(1) }
|
12
13
|
end
|
13
14
|
|
14
15
|
def configuration
|
@@ -54,4 +55,4 @@ module Micronaut
|
|
54
55
|
|
55
56
|
end
|
56
57
|
|
57
|
-
end
|
58
|
+
end
|
data/lib/micronaut/world.rb
CHANGED
@@ -8,16 +8,12 @@ module Micronaut
|
|
8
8
|
@behaviours = []
|
9
9
|
end
|
10
10
|
|
11
|
-
def filter
|
12
|
-
Micronaut.configuration.filter
|
13
|
-
end
|
14
|
-
|
15
11
|
def behaviours_to_run
|
16
12
|
return @behaviours_to_run if @behaviours_to_run
|
17
13
|
|
18
|
-
if
|
14
|
+
if Micronaut.configuration.filter_run
|
19
15
|
@behaviours_to_run = filter_behaviours
|
20
|
-
puts "\nRun filtered using #{
|
16
|
+
puts "\nRun filtered using #{Micronaut.configuration.filter_run.inspect}"
|
21
17
|
if @behaviours_to_run.size == 0 && Micronaut.configuration.run_all_when_everything_filtered?
|
22
18
|
puts "No behaviours were matched, running all"
|
23
19
|
# reset the behaviour list to all behaviours, and add back all examples
|
@@ -37,8 +33,8 @@ module Micronaut
|
|
37
33
|
|
38
34
|
def filter_behaviours
|
39
35
|
behaviours.inject([]) do |list, b|
|
40
|
-
b.examples_to_run.replace(find(b.examples,
|
41
|
-
#
|
36
|
+
b.examples_to_run.replace(find(b.examples, Micronaut.configuration.filter_run).uniq)
|
37
|
+
# Do not add behaviours with 0 examples to run
|
42
38
|
list << (b.examples_to_run.size == 0 ? nil : b)
|
43
39
|
end.compact
|
44
40
|
end
|
@@ -48,6 +44,10 @@ module Micronaut
|
|
48
44
|
conditions.all? { |filter_on, filter| apply_condition(filter_on, filter, item.metadata) }
|
49
45
|
end
|
50
46
|
end
|
47
|
+
|
48
|
+
def find_behaviours(conditions={})
|
49
|
+
find(behaviours, conditions)
|
50
|
+
end
|
51
51
|
|
52
52
|
def apply_condition(filter_on, filter, metadata)
|
53
53
|
return false if metadata.nil?
|
@@ -66,4 +66,4 @@ module Micronaut
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
-
end
|
69
|
+
end
|
data/lib/micronaut.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'micronaut/mocking'
|
1
|
+
require 'micronaut/mocking/with_absolutely_nothing'
|
2
2
|
require 'micronaut/matchers'
|
3
3
|
require 'micronaut/expectations'
|
4
4
|
require 'micronaut/world'
|
@@ -31,6 +31,7 @@ module Micronaut
|
|
31
31
|
|
32
32
|
def self.configure
|
33
33
|
yield configuration
|
34
|
+
configuration.autorun!
|
34
35
|
end
|
35
36
|
|
36
37
|
def self.world
|
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.7
|
4
|
+
version: 0.1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Humphries
|
@@ -72,7 +72,6 @@ files:
|
|
72
72
|
- lib/micronaut/mocking/with_absolutely_nothing.rb
|
73
73
|
- lib/micronaut/mocking/with_mocha.rb
|
74
74
|
- lib/micronaut/mocking/with_rr.rb
|
75
|
-
- lib/micronaut/mocking.rb
|
76
75
|
- lib/micronaut/runner.rb
|
77
76
|
- lib/micronaut/world.rb
|
78
77
|
- lib/micronaut.rb
|