spicycode-micronaut 0.1.4.3 → 0.1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/examples/example_helper.rb +1 -1
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +4 -4
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +63 -60
- data/lib/micronaut/behaviour.rb +1 -1
- data/lib/micronaut/formatters/base_formatter.rb +8 -12
- data/lib/micronaut/formatters/base_text_formatter.rb +4 -1
- data/lib/micronaut/formatters/progress_formatter.rb +2 -1
- data/lib/micronaut/runner.rb +16 -15
- metadata +1 -1
data/Rakefile
CHANGED
data/examples/example_helper.rb
CHANGED
@@ -37,6 +37,6 @@ Micronaut.configure do |config|
|
|
37
37
|
config.color_enabled = use_color?
|
38
38
|
config.formatter = :progress
|
39
39
|
config.profile_examples = false
|
40
|
-
config.filter_run :options => { :focused => true
|
40
|
+
config.filter_run :options => { :focused => true }
|
41
41
|
config.autorun!
|
42
42
|
end
|
@@ -84,16 +84,16 @@ describe Micronaut::Formatters::BaseFormatter do
|
|
84
84
|
@formatter.should have_interface_for(:example_pending).with(2).arguments
|
85
85
|
end
|
86
86
|
|
87
|
-
it "should have start_dump as an interface with
|
88
|
-
@formatter.should have_interface_for(:start_dump).with(
|
87
|
+
it "should have start_dump as an interface with 1 arguments" do
|
88
|
+
@formatter.should have_interface_for(:start_dump).with(1).arguments
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should have dump_failures as an interface with no arguments" do
|
92
92
|
@formatter.should have_interface_for(:dump_failures).with(0).arguments
|
93
93
|
end
|
94
94
|
|
95
|
-
it "should have dump_summary as an interface with
|
96
|
-
@formatter.should have_interface_for(:dump_summary).with(
|
95
|
+
it "should have dump_summary as an interface with zero arguments" do
|
96
|
+
@formatter.should have_interface_for(:dump_summary).with(0).arguments
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should have dump_pending as an interface with zero arguments" do
|
@@ -2,64 +2,67 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
|
2
2
|
|
3
3
|
describe Micronaut::Formatters::ProgressFormatter do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
5
|
+
before do
|
6
|
+
@output = StringIO.new
|
7
|
+
@formatter = Micronaut::Formatters::ProgressFormatter.new
|
8
|
+
@formatter.start(2)
|
9
|
+
@formatter.stubs(:color_enabled?).returns(false)
|
10
|
+
@formatter.stubs(:output).returns(@output)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should produce line break on start dump" do
|
14
|
+
@formatter.start_dump(3)
|
15
|
+
@output.string.should == "\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
19
|
+
@formatter.start_dump(3)
|
20
|
+
@formatter.dump_summary
|
21
|
+
@output.string.should =~ /Finished in 3 seconds\n2 examples/i
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should produce standard summary" do
|
25
|
+
@formatter.start_dump(3)
|
26
|
+
@formatter.example_pending(running_example, "message")
|
27
|
+
@output.rewind
|
28
|
+
@formatter.dump_summary
|
29
|
+
@output.string.should =~ /Finished in 3 seconds\n2 examples/i
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when color is enabled" do
|
33
|
+
|
34
|
+
before do
|
35
|
+
@formatter.stubs(:color_enabled?).returns(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should output a green dot for passing spec" do
|
39
|
+
@formatter.example_passed("spec")
|
40
|
+
@output.string.should == "\e[32m.\e[0m"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should push red F for failure spec" do
|
44
|
+
@formatter.example_failed("spec", Micronaut::Expectations::ExpectationNotMetError.new)
|
45
|
+
@output.string.should == "\e[31mF\e[0m"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should push magenta F for error spec" do
|
49
|
+
@formatter.example_failed("spec", RuntimeError.new)
|
50
|
+
@output.string.should == "\e[35mF\e[0m"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should push nothing on start" do
|
56
|
+
@formatter.start(4)
|
57
|
+
@output.string.should == ""
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should ensure two ':' in the first backtrace" do
|
61
|
+
backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
62
|
+
@formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1"
|
63
|
+
|
64
|
+
backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
|
65
|
+
@formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1: message"
|
66
|
+
end
|
67
|
+
|
65
68
|
end
|
data/lib/micronaut/behaviour.rb
CHANGED
@@ -2,10 +2,12 @@ module Micronaut
|
|
2
2
|
module Formatters
|
3
3
|
|
4
4
|
class BaseFormatter
|
5
|
-
attr_accessor :behaviour
|
5
|
+
attr_accessor :behaviour, :total_example_failed, :total_example_pending
|
6
|
+
attr_reader :example_count, :duration
|
6
7
|
|
7
8
|
def initialize
|
8
|
-
@total_example_failed, @total_example_pending, @
|
9
|
+
@total_example_failed, @total_example_pending, @example_count = 0, 0, 0
|
10
|
+
@behaviour = nil
|
9
11
|
end
|
10
12
|
|
11
13
|
def configuration
|
@@ -24,14 +26,6 @@ module Micronaut
|
|
24
26
|
configuration.color_enabled?
|
25
27
|
end
|
26
28
|
|
27
|
-
def total_example_failed
|
28
|
-
@total_example_failed
|
29
|
-
end
|
30
|
-
|
31
|
-
def total_example_pending
|
32
|
-
@total_example_pending
|
33
|
-
end
|
34
|
-
|
35
29
|
def example_profiling_info
|
36
30
|
@example_profiling_info ||= []
|
37
31
|
end
|
@@ -51,6 +45,7 @@ module Micronaut
|
|
51
45
|
# This method will only be invoked once, and the next one to be invoked
|
52
46
|
# is #add_behaviour
|
53
47
|
def start(example_count)
|
48
|
+
@example_count = example_count
|
54
49
|
end
|
55
50
|
|
56
51
|
# This method is invoked at the beginning of the execution of each behaviour.
|
@@ -89,7 +84,8 @@ module Micronaut
|
|
89
84
|
|
90
85
|
# This method is invoked after all of the examples have executed. The next method
|
91
86
|
# to be invoked after this one is #dump_failure (once for each failed example),
|
92
|
-
def start_dump
|
87
|
+
def start_dump(duration)
|
88
|
+
@duration = duration
|
93
89
|
end
|
94
90
|
|
95
91
|
# Dumps detailed information about each example failure.
|
@@ -97,7 +93,7 @@ module Micronaut
|
|
97
93
|
end
|
98
94
|
|
99
95
|
# This method is invoked after the dumping of examples and failures.
|
100
|
-
def dump_summary
|
96
|
+
def dump_summary
|
101
97
|
end
|
102
98
|
|
103
99
|
# This gets invoked after the summary if option is set to do so.
|
@@ -47,7 +47,10 @@ module Micronaut
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def dump_summary
|
50
|
+
def dump_summary
|
51
|
+
failure_count = failed_examples.size
|
52
|
+
pending_count = pending_examples.size
|
53
|
+
|
51
54
|
output.puts "\nFinished in #{duration} seconds\n"
|
52
55
|
|
53
56
|
summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failures"
|
data/lib/micronaut/runner.rb
CHANGED
@@ -10,43 +10,44 @@ module Micronaut
|
|
10
10
|
at_exit { Micronaut::Runner.new.run(ARGV) ? exit(0) : exit(1) } unless installed_at_exit?
|
11
11
|
@installed_at_exit = true
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def configuration
|
15
15
|
Micronaut.configuration
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def formatter
|
19
19
|
Micronaut.configuration.formatter
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def require_all_behaviours(files_from_args=[])
|
23
23
|
files_from_args.each { |file| require file }
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def run(args = [])
|
27
27
|
require_all_behaviours(args)
|
28
|
-
|
28
|
+
|
29
29
|
total_examples_to_run = Micronaut.world.total_examples_to_run
|
30
30
|
|
31
31
|
old_sync, formatter.output.sync = formatter.output.sync, true if formatter.output.respond_to?(:sync=)
|
32
32
|
|
33
|
-
formatter.start(total_examples_to_run)
|
34
|
-
|
35
33
|
suite_success = true
|
36
34
|
|
37
|
-
|
35
|
+
formatter_supports_sync = formatter.output.respond_to?(:sync=)
|
36
|
+
old_sync, formatter.output.sync = formatter.output.sync, true if formatter_supports_sync
|
37
|
+
|
38
|
+
formatter.start(total_examples_to_run) # start the clock
|
39
|
+
start = Time.now
|
38
40
|
Micronaut.world.behaviours_to_run.each do |behaviour|
|
39
41
|
suite_success &= behaviour.run(formatter)
|
40
42
|
end
|
41
|
-
|
42
|
-
|
43
|
-
formatter.start_dump
|
43
|
+
formatter.start_dump(Time.now - start)
|
44
|
+
|
44
45
|
formatter.dump_failures
|
45
|
-
|
46
|
-
formatter.dump_summary(duration, total_examples_to_run, formatter.failed_examples.size, formatter.pending_examples.size)
|
46
|
+
formatter.dump_summary
|
47
47
|
formatter.dump_pending
|
48
|
-
|
49
|
-
|
48
|
+
formatter.close
|
49
|
+
|
50
|
+
formatter.output.sync = old_sync if formatter_supports_sync
|
50
51
|
|
51
52
|
suite_success
|
52
53
|
end
|