spicycode-micronaut 0.1.3 → 0.1.4
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 +2 -1
- data/examples/lib/micronaut/configuration_example.rb +9 -9
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +21 -25
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -2
- 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/lib/micronaut/behaviour.rb +1 -1
- data/lib/micronaut/configuration.rb +3 -0
- data/lib/micronaut/formatters/base_formatter.rb +5 -0
- data/lib/micronaut/formatters/base_text_formatter.rb +29 -1
- metadata +2 -4
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)
|
@@ -2,9 +2,11 @@ module Micronaut
|
|
2
2
|
|
3
3
|
class Configuration
|
4
4
|
attr_reader :mock_framework, :backtrace_clean_patterns, :behaviour_filters
|
5
|
+
attr_accessor :profile_examples
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/]
|
9
|
+
@profile_examples = false
|
8
10
|
end
|
9
11
|
|
10
12
|
def cleaned_from_backtrace?(line)
|
@@ -40,6 +42,7 @@ module Micronaut
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def options
|
45
|
+
# Do we need this?
|
43
46
|
@options ||= Micronaut::RunnerOptions.new(:color => true, :formatter => :documentation)
|
44
47
|
end
|
45
48
|
|
@@ -8,6 +8,10 @@ module Micronaut
|
|
8
8
|
@options, @output = options, output_to
|
9
9
|
@total_example_failed, @total_example_pending = 0, 0
|
10
10
|
end
|
11
|
+
|
12
|
+
def profile_examples?
|
13
|
+
Micronaut.configuration.profile_examples
|
14
|
+
end
|
11
15
|
|
12
16
|
# This method is invoked before any examples are run, right after
|
13
17
|
# they have all been collected. This can be useful for special
|
@@ -28,6 +32,7 @@ module Micronaut
|
|
28
32
|
|
29
33
|
# This method is invoked when an +example+ starts.
|
30
34
|
def example_started(example)
|
35
|
+
|
31
36
|
end
|
32
37
|
|
33
38
|
# This method is invoked when an +example+ passes.
|
@@ -9,6 +9,19 @@ module Micronaut
|
|
9
9
|
super
|
10
10
|
@pending_examples = []
|
11
11
|
@failed_examples = []
|
12
|
+
@example_profiling_info = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def example_passed(example)
|
16
|
+
super
|
17
|
+
# Why && @start_time
|
18
|
+
if profile_examples? && @start_time
|
19
|
+
@example_profiling_info << [example, Time.now - @start_time]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def example_started(example)
|
24
|
+
@start_time = Time.now
|
12
25
|
end
|
13
26
|
|
14
27
|
def example_pending(example, message)
|
@@ -20,7 +33,7 @@ module Micronaut
|
|
20
33
|
@failed_examples << [example, exception]
|
21
34
|
end
|
22
35
|
|
23
|
-
def dump_failures
|
36
|
+
def dump_failures
|
24
37
|
@output.puts
|
25
38
|
@failed_examples.each_with_index do |examples_with_exception, index|
|
26
39
|
example, exception = examples_with_exception.first, examples_with_exception.last
|
@@ -55,6 +68,16 @@ module Micronaut
|
|
55
68
|
else
|
56
69
|
@output.puts red(summary)
|
57
70
|
end
|
71
|
+
|
72
|
+
if profile_examples?
|
73
|
+
sorted_examples = @example_profiling_info.sort_by { |desc, time| time }
|
74
|
+
@output.puts "\nTop 10 slowest examples:\n"
|
75
|
+
sorted_examples.last(10).reverse.each do |desc, time|
|
76
|
+
@output.puts " (#{sprintf("%.7f", time)} seconds) #{desc}"
|
77
|
+
@output.puts grey(" # #{desc.options[:caller]}")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
58
81
|
@output.flush
|
59
82
|
end
|
60
83
|
|
@@ -64,6 +87,7 @@ module Micronaut
|
|
64
87
|
@output.puts "Pending:"
|
65
88
|
@pending_examples.each do |pending_example, message|
|
66
89
|
@output.puts "\n #{pending_example.behaviour}\n - #{pending_example.description}"
|
90
|
+
@output.puts grey(" # #{pending_example.options[:caller]}")
|
67
91
|
end
|
68
92
|
end
|
69
93
|
@output.flush
|
@@ -118,6 +142,10 @@ module Micronaut
|
|
118
142
|
def blue(text)
|
119
143
|
color(text, "\e[34m")
|
120
144
|
end
|
145
|
+
|
146
|
+
def grey(text)
|
147
|
+
color(text, "\e[90m")
|
148
|
+
end
|
121
149
|
|
122
150
|
end
|
123
151
|
|
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.4
|
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-17 00:00:00 -08:00
|
13
13
|
default_executable: micronaut
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -36,11 +36,9 @@ files:
|
|
36
36
|
- lib/micronaut/configuration.rb
|
37
37
|
- lib/micronaut/example.rb
|
38
38
|
- lib/micronaut/expectations
|
39
|
-
- lib/micronaut/expectations/errors.rb
|
40
39
|
- lib/micronaut/expectations/extensions
|
41
40
|
- lib/micronaut/expectations/extensions/object.rb
|
42
41
|
- lib/micronaut/expectations/extensions/string_and_symbol.rb
|
43
|
-
- lib/micronaut/expectations/extensions.rb
|
44
42
|
- lib/micronaut/expectations/handler.rb
|
45
43
|
- lib/micronaut/expectations/wrap_expectation.rb
|
46
44
|
- lib/micronaut/expectations.rb
|