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 CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
  require 'rubygems/specification'
4
4
 
5
5
  GEM = "micronaut"
6
- GEM_VERSION = "0.1.4.3"
6
+ GEM_VERSION = "0.1.4.4"
7
7
  AUTHOR = "Chad Humphries"
8
8
  EMAIL = "chad@spicycode.com"
9
9
  HOMEPAGE = "http://spicycode.com"
@@ -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, :using_mocks => 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 zero arguments" do
88
- @formatter.should have_interface_for(:start_dump).with(0).arguments
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 4 arguments" do
96
- @formatter.should have_interface_for(:dump_summary).with(4).arguments
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
- before do
6
- @output = StringIO.new
7
- @formatter = Micronaut::Formatters::ProgressFormatter.new
8
- @formatter.stubs(:color_enabled?).returns(false)
9
- @formatter.stubs(:output).returns(@output)
10
- end
11
-
12
- it "should produce line break on start dump" do
13
- @formatter.start_dump
14
- @output.string.should == "\n"
15
- end
16
-
17
- it "should produce standard summary without pending when pending has a 0 count" do
18
- @formatter.dump_summary(3, 2, 1, 0)
19
- @output.string.should =~ /Finished in 3 seconds\n2 examples, 1 failures/i
20
- end
21
-
22
- it "should produce standard summary" do
23
- @formatter.example_pending(running_example, "message")
24
- @output.rewind
25
- @formatter.dump_summary(3, 2, 1, 1)
26
- @output.string.should =~ /Finished in 3 seconds\n2 examples, 1 failures, 1 pending/i
27
- end
28
-
29
- describe "when color is enabled" do
30
-
31
- before do
32
- @formatter.stubs(:color_enabled?).returns(true)
33
- end
34
-
35
- it "should output a green dot for passing spec" do
36
- @formatter.example_passed("spec")
37
- @output.string.should == "\e[32m.\e[0m"
38
- end
39
-
40
- it "should push red F for failure spec" do
41
- @formatter.example_failed("spec", Micronaut::Expectations::ExpectationNotMetError.new)
42
- @output.string.should == "\e[31mF\e[0m"
43
- end
44
-
45
- it "should push magenta F for error spec" do
46
- @formatter.example_failed("spec", RuntimeError.new)
47
- @output.string.should == "\e[35mF\e[0m"
48
- end
49
-
50
- end
51
-
52
- it "should push nothing on start" do
53
- @formatter.start(4)
54
- @output.string.should == ""
55
- end
56
-
57
- it "should ensure two ':' in the first backtrace" do
58
- backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"]
59
- @formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1"
60
-
61
- backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"]
62
- @formatter.format_backtrace(backtrace).should == "/tmp/x.rb:1: message"
63
- end
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
@@ -166,7 +166,7 @@ module Micronaut
166
166
  eval_before_alls(group)
167
167
  success = true
168
168
 
169
- examples.each do |ex|
169
+ examples_to_run.each do |ex|
170
170
  group.running_example = ex
171
171
  reporter.example_started(ex)
172
172
 
@@ -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, @behaviour = 0, 0, nil
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(duration, example_count, failure_count, pending_count)
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(duration, example_count, failure_count, pending_count)
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"
@@ -21,7 +21,8 @@ module Micronaut
21
21
  output.flush
22
22
  end
23
23
 
24
- def start_dump
24
+ def start_dump(duration)
25
+ super
25
26
  output.puts
26
27
  output.flush
27
28
  end
@@ -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
- starts_at = Time.now
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
- duration = Time.now - starts_at
42
-
43
- formatter.start_dump
43
+ formatter.start_dump(Time.now - start)
44
+
44
45
  formatter.dump_failures
45
- # TODO: Stop passing in the last two items, the formatter knows this info
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
- formatter.output.sync = old_sync if formatter.output.respond_to? :sync=
48
+ formatter.close
49
+
50
+ formatter.output.sync = old_sync if formatter_supports_sync
50
51
 
51
52
  suite_success
52
53
  end
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.3
4
+ version: 0.1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Humphries