spicycode-micronaut 0.1.6 → 0.1.6.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/lib/micronaut/behaviour_example.rb +4 -4
- data/examples/lib/micronaut/world_example.rb +5 -9
- data/lib/micronaut/behaviour.rb +21 -17
- data/lib/micronaut/example.rb +2 -15
- data/lib/micronaut/formatters/base_formatter.rb +6 -3
- data/lib/micronaut/world.rb +16 -15
- metadata +2 -2
data/Rakefile
CHANGED
@@ -29,14 +29,14 @@ describe Micronaut::Behaviour do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
-
describe '#
|
32
|
+
describe '#describes' do
|
33
33
|
|
34
34
|
it "should be the first parameter when it is a constant" do
|
35
|
-
Micronaut::Behaviour.describe(Object) { }.
|
35
|
+
Micronaut::Behaviour.describe(Object) { }.describes.should == Object
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be nil when the first parameter is a string" do
|
39
|
-
Micronaut::Behaviour.describe("i'm a computer") { }.
|
39
|
+
Micronaut::Behaviour.describe("i'm a computer") { }.describes.should be_nil
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
@@ -168,7 +168,7 @@ describe Micronaut::Behaviour do
|
|
168
168
|
describe "A sample nested describe", :just_testing => 'yep' do
|
169
169
|
|
170
170
|
it "should set the described type to the constant Object" do
|
171
|
-
running_example.behaviour.
|
171
|
+
running_example.behaviour.describes.should == Object
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should set the description to 'A sample nested describe'" do
|
@@ -46,20 +46,20 @@ describe Micronaut::World do
|
|
46
46
|
@world.find([]).should == []
|
47
47
|
end
|
48
48
|
|
49
|
-
it "should find three groups when searching for :
|
50
|
-
@world.find(@behaviours, :
|
49
|
+
it "should find three groups when searching for :behaviour_describes => Bar" do
|
50
|
+
@world.find(@behaviours, :behaviour => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should find one group when searching for :description => 'find group-1'" do
|
54
|
-
@world.find(@behaviours, :description => 'find group-1').should == [@bg1]
|
54
|
+
@world.find(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should find two groups when searching for :description => lambda { |v| v.include?('-1') || v.include?('-3') }" do
|
58
|
-
@world.find(@behaviours, :description => lambda { |v| v.include?('-1') || v.include?('-3') }).should == [@bg1, @bg3]
|
58
|
+
@world.find(@behaviours, :behaviour => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should find three groups when searching for :description => /find group/" do
|
62
|
-
@world.find(@behaviours, :description => /find group/).should == [@bg1, @bg2, @bg3]
|
62
|
+
@world.find(@behaviours, :behaviour => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should find one group when searching for :foo => 1" do
|
@@ -87,9 +87,5 @@ describe Micronaut::World do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|
90
|
-
|
91
|
-
describe '#filter_behaviours' do
|
92
|
-
|
93
|
-
end
|
94
90
|
|
95
91
|
end
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -75,20 +75,24 @@ module Micronaut
|
|
75
75
|
# This method is friggin' gigantic, and must be stopped
|
76
76
|
#
|
77
77
|
def self.set_it_up(*args)
|
78
|
-
@metadata = {}
|
78
|
+
@metadata = {:behaviour => {}}
|
79
79
|
extra_metadata = args.last.is_a?(Hash) ? args.pop : {}
|
80
80
|
if args.first.is_a?(String)
|
81
|
-
@metadata[:
|
81
|
+
@metadata[:behaviour][:describes] = self.superclass.metadata && self.superclass.metadata[:behaviour][:describes]
|
82
82
|
else
|
83
|
-
@metadata[:
|
83
|
+
@metadata[:behaviour][:describes] = args.shift
|
84
84
|
end
|
85
|
-
@metadata[:description] = args.shift || ''
|
86
|
-
@metadata[:name] = "#{
|
87
|
-
extra_metadata.
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
@metadata[:behaviour][:description] = args.shift || ''
|
86
|
+
@metadata[:behaviour][:name] = "#{describes} #{description}".strip
|
87
|
+
@metadata[:behaviour][:block] = extra_metadata.delete(:behaviour_block)
|
88
|
+
@metadata[:behaviour][:file_path] = eval("caller(0)[0]", @metadata[:behaviour][:block].binding)
|
89
|
+
|
90
|
+
extra_metadata.delete(:behaviour) # Remove it if it is present
|
91
|
+
@metadata.update(extra_metadata)
|
91
92
|
|
93
|
+
# should this be here? I think it should be in the runner, the only possible
|
94
|
+
# point of contention is whether or not inserted/extended modules should be
|
95
|
+
# allowed to participate in adding metadata. If they can, then earlier is better
|
92
96
|
Micronaut.configuration.find_modules(self).each do |include_or_extend, mod, opts|
|
93
97
|
if include_or_extend == :extend
|
94
98
|
send(:extend, mod) unless extended_modules.include?(mod)
|
@@ -103,26 +107,26 @@ module Micronaut
|
|
103
107
|
end
|
104
108
|
|
105
109
|
def self.name
|
106
|
-
@metadata[:name]
|
110
|
+
@metadata[:behaviour][:name]
|
107
111
|
end
|
108
112
|
|
109
|
-
def self.
|
110
|
-
@metadata[:
|
113
|
+
def self.describes
|
114
|
+
@metadata[:behaviour][:describes]
|
111
115
|
end
|
112
116
|
|
113
117
|
def self.description
|
114
|
-
@metadata[:description]
|
118
|
+
@metadata[:behaviour][:description]
|
115
119
|
end
|
116
120
|
|
117
|
-
def self.describe(*args, &
|
121
|
+
def self.describe(*args, &behaviour_block)
|
118
122
|
raise(ArgumentError, "No arguments given. You must a least supply a type or description") if args.empty?
|
119
|
-
raise(ArgumentError, "You must supply a block when calling describe") if
|
123
|
+
raise(ArgumentError, "You must supply a block when calling describe") if behaviour_block.nil?
|
120
124
|
|
121
125
|
subclass('NestedLevel') do
|
122
126
|
args << {} unless args.last.is_a?(Hash)
|
123
|
-
args.last.update(:
|
127
|
+
args.last.update(:behaviour_block => behaviour_block)
|
124
128
|
set_it_up(*args)
|
125
|
-
module_eval(&
|
129
|
+
module_eval(&behaviour_block)
|
126
130
|
end
|
127
131
|
end
|
128
132
|
|
data/lib/micronaut/example.rb
CHANGED
@@ -6,22 +6,9 @@ module Micronaut
|
|
6
6
|
|
7
7
|
def initialize(behaviour, desc, options, example_block=nil)
|
8
8
|
@behaviour, @description, @options, @example_block = behaviour, desc, options, example_block
|
9
|
-
@metadata =
|
10
|
-
behaviour.metadata.each do |k, v|
|
11
|
-
@metadata[k] = v
|
12
|
-
end
|
9
|
+
@metadata = @behaviour.metadata.dup
|
13
10
|
@metadata[:description] = description
|
14
|
-
options
|
15
|
-
@metadata[k] = v
|
16
|
-
end
|
17
|
-
#
|
18
|
-
# if @metadata[:options].has_key?(:focused)
|
19
|
-
# puts "self.inspect => #{self.inspect}"
|
20
|
-
# puts "@metadata[:description] => #{@metadata[:description]}"
|
21
|
-
# puts "@options.has_key?(:focused) => #{@options.has_key?(:focused)}"
|
22
|
-
# puts "@metadata[:options].has_key?(:focused) => #{@metadata[:options].has_key?(:focused)}"
|
23
|
-
# puts
|
24
|
-
# end
|
11
|
+
@metadata.update(options)
|
25
12
|
end
|
26
13
|
|
27
14
|
def inspect
|
@@ -107,7 +107,7 @@ module Micronaut
|
|
107
107
|
def format_backtrace(backtrace, example)
|
108
108
|
return "" if backtrace.nil?
|
109
109
|
cleansed = backtrace.map { |line| backtrace_line(line) }.compact
|
110
|
-
original_file = example.behaviour.metadata[:file_path].split(':').first.strip
|
110
|
+
original_file = example.behaviour.metadata[:behaviour][:file_path].split(':').first.strip
|
111
111
|
# cleansed = cleansed.select do |line|
|
112
112
|
# line.split(':').first.downcase == original_file.downcase
|
113
113
|
# end
|
@@ -131,9 +131,12 @@ module Micronaut
|
|
131
131
|
line.split(':').first.downcase == original_file.downcase
|
132
132
|
end
|
133
133
|
return "Unable to find matching line from backtrace" if matching_line.nil?
|
134
|
-
|
135
134
|
file_path, line_number = matching_line.split(':')
|
136
|
-
|
135
|
+
if File.exist?(file_path)
|
136
|
+
open(file_path, 'r') { |f| f.readlines[line_number.to_i - 1] }
|
137
|
+
else
|
138
|
+
"Unable to find #{file_path} to read failed line"
|
139
|
+
end
|
137
140
|
end
|
138
141
|
|
139
142
|
end
|
data/lib/micronaut/world.rb
CHANGED
@@ -19,7 +19,7 @@ module Micronaut
|
|
19
19
|
@behaviours_to_run = filter_behaviours
|
20
20
|
puts "\nRun filtered using #{filter.inspect}"
|
21
21
|
if @behaviours_to_run.size == 0 && Micronaut.configuration.run_all_when_everything_filtered?
|
22
|
-
puts "No behaviours
|
22
|
+
puts "No behaviours were matched, running all"
|
23
23
|
# reset the behaviour list to all behaviours, and add back all examples
|
24
24
|
@behaviours_to_run = @behaviours
|
25
25
|
@behaviours.each { |b| b.examples_to_run.replace(b.examples) }
|
@@ -38,26 +38,27 @@ module Micronaut
|
|
38
38
|
def filter_behaviours
|
39
39
|
behaviours.inject([]) do |list, b|
|
40
40
|
b.examples_to_run.replace(find(b.examples, filter).uniq)
|
41
|
+
# Don't add behaviours with no examples to run onto the suite run
|
41
42
|
list << (b.examples_to_run.size == 0 ? nil : b)
|
42
43
|
end.compact
|
43
44
|
end
|
44
45
|
|
45
46
|
def find(collection, conditions={})
|
46
|
-
return [] if conditions.empty?
|
47
|
-
|
48
47
|
collection.select do |item|
|
49
|
-
conditions.all?
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
48
|
+
conditions.all? { |filter_on, filter| apply_condition(filter_on, filter, item.metadata) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def apply_condition(filter_on, filter, metadata)
|
53
|
+
case filter
|
54
|
+
when Hash
|
55
|
+
filter.all? { |k, v| apply_condition(k, v, metadata[filter_on]) }
|
56
|
+
when Regexp
|
57
|
+
metadata[filter_on] =~ filter
|
58
|
+
when Proc
|
59
|
+
filter.call(metadata[filter_on]) rescue false
|
60
|
+
else
|
61
|
+
metadata[filter_on] == filter
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
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.6
|
4
|
+
version: 0.1.6.1
|
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: 2008-12-
|
12
|
+
date: 2008-12-23 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|