rsanheim-micronaut 0.1.3.2 → 0.1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -3
- data/examples/example_helper.rb +1 -1
- data/examples/lib/micronaut/behaviour_example.rb +14 -8
- data/examples/lib/micronaut/configuration_example.rb +8 -8
- data/examples/lib/micronaut/example_example.rb +6 -0
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +16 -20
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +0 -4
- data/examples/lib/micronaut/matchers/matcher_methods_example.rb +73 -61
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +141 -137
- data/examples/lib/micronaut/matchers/raise_error_example.rb +251 -249
- data/examples/lib/micronaut/world_example.rb +14 -1
- data/lib/micronaut/behaviour.rb +2 -2
- data/lib/micronaut/formatters/base_text_formatter.rb +19 -6
- data/lib/micronaut/runner.rb +1 -2
- metadata +1 -1
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
2
|
|
3
3
|
class Bar; end
|
4
|
+
class Foo; end
|
4
5
|
|
5
6
|
describe Micronaut::World do
|
6
7
|
|
@@ -23,13 +24,25 @@ describe Micronaut::World do
|
|
23
24
|
@bg1 = Micronaut::Behaviour.describe(Bar, "find group-1", options_1) { }
|
24
25
|
@bg2 = Micronaut::Behaviour.describe(Bar, "find group-2", options_2) { }
|
25
26
|
@bg3 = Micronaut::Behaviour.describe(Bar, "find group-3", options_3) { }
|
26
|
-
@
|
27
|
+
@bg4 = Micronaut::Behaviour.describe(Foo, "find these examples") do
|
28
|
+
it('I have no options') {}
|
29
|
+
it("this is awesome", :awesome => true) {}
|
30
|
+
it("this is too", :awesome => true) {}
|
31
|
+
it("not so awesome", :awesome => false) {}
|
32
|
+
it("I also have no options") {}
|
33
|
+
end
|
34
|
+
@behaviours = [@bg1, @bg2, @bg3, @bg4]
|
27
35
|
end
|
28
36
|
|
29
37
|
after(:all) do
|
30
38
|
Micronaut::World.behaviours.delete(@bg1)
|
31
39
|
Micronaut::World.behaviours.delete(@bg2)
|
32
40
|
Micronaut::World.behaviours.delete(@bg3)
|
41
|
+
Micronaut::World.behaviours.delete(@bg4)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should find awesome examples" do
|
45
|
+
Micronaut::World.find(@bg4.examples, :options => {:awesome => true}).should == [@bg4.examples[1], @bg4.examples[2]]
|
33
46
|
end
|
34
47
|
|
35
48
|
it "should find no groups when given no search parameters" do
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -45,7 +45,7 @@ module Micronaut
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.it(desc=nil, options={}, &block)
|
48
|
-
examples << Micronaut::Example.new(self, desc, options, block)
|
48
|
+
examples << Micronaut::Example.new(self, desc, options.update(:caller => caller[0]), block)
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.focused(desc=nil, options={}, &block)
|
@@ -206,6 +206,6 @@ module Micronaut
|
|
206
206
|
def self.to_s
|
207
207
|
self == Micronaut::Behaviour ? 'Micronaut::Behaviour' : name
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
end
|
211
211
|
end
|
@@ -33,17 +33,24 @@ module Micronaut
|
|
33
33
|
@failed_examples << [example, exception]
|
34
34
|
end
|
35
35
|
|
36
|
-
def dump_failures
|
36
|
+
def dump_failures
|
37
37
|
@output.puts
|
38
38
|
@failed_examples.each_with_index do |examples_with_exception, index|
|
39
39
|
example, exception = examples_with_exception.first, examples_with_exception.last
|
40
|
+
padding = ' '
|
40
41
|
@output.puts "#{index.next}) #{example}"
|
41
|
-
@output.puts
|
42
|
-
@output.puts
|
42
|
+
# @output.puts "#{padding}failing statement: #{read_failed_line(example.options[:caller])}\n"
|
43
|
+
@output.puts "#{padding}#{colorise(exception.message, exception).strip}"
|
44
|
+
@output.puts grey("#{padding}# #{format_backtrace(exception.backtrace)}")
|
43
45
|
@output.puts
|
44
46
|
@output.flush
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
def read_failed_line(file_path_with_line_number)
|
51
|
+
file_path, line_number = file_path_with_line_number.split(':')
|
52
|
+
open(file_path, 'r') { |f| f.readlines[line_number.to_i + 1].strip }
|
53
|
+
end
|
47
54
|
|
48
55
|
def colorise(s, failure)
|
49
56
|
if failure.is_a?(Micronaut::Expectations::ExpectationNotMetError)
|
@@ -56,7 +63,7 @@ module Micronaut
|
|
56
63
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
57
64
|
@output.puts "\nFinished in #{duration} seconds\n"
|
58
65
|
|
59
|
-
summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count}
|
66
|
+
summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failures"
|
60
67
|
summary << ", #{pending_count} pending" if pending_count > 0
|
61
68
|
|
62
69
|
if failure_count == 0
|
@@ -74,6 +81,7 @@ module Micronaut
|
|
74
81
|
@output.puts "\nTop 10 slowest examples:\n"
|
75
82
|
sorted_examples.last(10).reverse.each do |desc, time|
|
76
83
|
@output.puts " (#{sprintf("%.7f", time)} seconds) #{desc}"
|
84
|
+
@output.puts grey(" # #{desc.options[:caller]}")
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
@@ -86,6 +94,7 @@ module Micronaut
|
|
86
94
|
@output.puts "Pending:"
|
87
95
|
@pending_examples.each do |pending_example, message|
|
88
96
|
@output.puts "\n #{pending_example.behaviour}\n - #{pending_example.description}"
|
97
|
+
@output.puts grey(" # #{pending_example.options[:caller]}")
|
89
98
|
end
|
90
99
|
end
|
91
100
|
@output.flush
|
@@ -99,8 +108,8 @@ module Micronaut
|
|
99
108
|
|
100
109
|
def format_backtrace(backtrace)
|
101
110
|
return "" if backtrace.nil?
|
102
|
-
cleansed = backtrace.map { |line| backtrace_line(line) }.compact
|
103
|
-
cleansed.empty? ? backtrace : cleansed
|
111
|
+
cleansed = backtrace.map { |line| backtrace_line(line) }.compact
|
112
|
+
cleansed.empty? ? backtrace.join("\n") : cleansed.first
|
104
113
|
end
|
105
114
|
|
106
115
|
protected
|
@@ -140,6 +149,10 @@ module Micronaut
|
|
140
149
|
def blue(text)
|
141
150
|
color(text, "\e[34m")
|
142
151
|
end
|
152
|
+
|
153
|
+
def grey(text)
|
154
|
+
color(text, "\e[90m")
|
155
|
+
end
|
143
156
|
|
144
157
|
end
|
145
158
|
|
data/lib/micronaut/runner.rb
CHANGED
@@ -41,11 +41,10 @@ module Micronaut
|
|
41
41
|
duration = Time.now - starts_at
|
42
42
|
|
43
43
|
options.formatter.start_dump
|
44
|
-
options.formatter.dump_pending
|
45
44
|
options.formatter.dump_failures
|
46
|
-
|
47
45
|
# TODO: Stop passing in the last two items, the formatter knows this info
|
48
46
|
options.formatter.dump_summary(duration, total_examples, options.formatter.failed_examples.size, options.formatter.pending_examples.size)
|
47
|
+
options.formatter.dump_pending
|
49
48
|
|
50
49
|
options.formatter.output.sync = old_sync if options.formatter.output.respond_to? :sync=
|
51
50
|
|