ci_reporter 1.6.4 → 1.6.5

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/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.6.5 (06/14/11)
2
+
3
+ - Works with RSpec up to 2.6.x
4
+ - GH #31: Better output formatting for RSpec 2 (Michael Giambalvo)
5
+ - Better ruby-test/TestUnit version support (amfranz)
6
+ - Prevent XML files from being overwritten (dpree)
7
+
1
8
  == 1.6.4 (12/21/10)
2
9
 
3
10
  - RSpec 2.2+ support (thanks emi)
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt",
4
4
  begin
5
5
  File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
6
6
  require 'hoe'
7
+ Hoe.plugin :rubyforge
7
8
  require File.dirname(__FILE__) + '/lib/ci/reporter/version'
8
9
  hoe = Hoe.spec("ci_reporter") do |p|
9
10
  p.version = CI::Reporter::VERSION
@@ -19,7 +20,6 @@ begin
19
20
  p.extra_deps << ['builder', ">= 2.1.2"]
20
21
  end
21
22
  hoe.spec.files = MANIFEST
22
- hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
23
23
  hoe.spec.rdoc_options += ["-SHN", "-f", "darkfish"]
24
24
 
25
25
  task :gemspec do
@@ -101,7 +101,12 @@ module CI
101
101
  end
102
102
 
103
103
  def before_table_row(table_row)
104
- @test_case = TestCase.new("#@scenario (outline: #{table_row.name})")
104
+ row = table_row # shorthand for table_row
105
+ # check multiple versions of the row and try to find the best fit
106
+ outline = (row.respond_to? :name) ? row.name :
107
+ (row.respond_to? :scenario_outline) ? row.scenario_outline :
108
+ row.to_s
109
+ @test_case = TestCase.new("#@scenario (outline: #{outline})")
105
110
  @test_case.start
106
111
  end
107
112
 
@@ -5,6 +5,7 @@
5
5
  $: << File.dirname(__FILE__) + "/../../.."
6
6
  require 'ci/reporter/test_unit'
7
7
 
8
+ # Intercepts mediator creation in ruby-test < 2.1
8
9
  module Test #:nodoc:all
9
10
  module Unit
10
11
  module UI
@@ -19,3 +20,17 @@ module Test #:nodoc:all
19
20
  end
20
21
  end
21
22
  end
23
+
24
+ # Intercepts mediator creation in ruby-test >= 2.1
25
+ module Test #:nodoc:all
26
+ module Unit
27
+ module UI
28
+ class TestRunner
29
+ def setup_mediator
30
+ # swap in our custom mediator
31
+ @mediator = CI::Reporter::TestUnit.new(@suite)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -14,10 +14,44 @@ module CI #:nodoc:
14
14
  end
15
15
 
16
16
  def write_report(suite)
17
- File.open("#{@basename}-#{suite.name.gsub(/[^a-zA-Z0-9]+/, '-')}.xml", "w") do |f|
17
+ File.open(filename_for(suite), "w") do |f|
18
18
  f << suite.to_xml
19
19
  end
20
20
  end
21
+
22
+ private
23
+
24
+
25
+ # creates a uniqe filename per suite
26
+ # to prevent results from being overwritten
27
+ # if a result file is already written, it appends an index
28
+ # e.g.
29
+ # SPEC-MailsController.xml
30
+ # SPEC-MailsController.0.xml
31
+ # SPEC-MailsController.1.xml
32
+ # SPEC-MailsController...xml
33
+ # SPEC-MailsController.N.xml
34
+ #
35
+ # with N < 100000, to prevent endless sidestep loops
36
+ MAX_SIDESTEPS = 100000
37
+ #
38
+ def filename_for(suite)
39
+ basename = "#{@basename}-#{suite.name.gsub(/[^a-zA-Z0-9]+/, '-')}"
40
+ suffix = "xml"
41
+
42
+ # the initial filename, e.g. SPEC-MailsController.xml
43
+ filename = [basename, suffix].join(".")
44
+
45
+ # if the initial filename is already in use
46
+ # do sidesteps, beginning with SPEC-MailsController.0.xml
47
+ i = 0
48
+ while File.exists?(filename) && i < MAX_SIDESTEPS
49
+ filename = [basename, i, suffix].join(".")
50
+ i += 1
51
+ end
52
+
53
+ filename
54
+ end
21
55
  end
22
56
  end
23
57
  end
@@ -49,7 +49,8 @@ module CI
49
49
  end
50
50
 
51
51
  class RSpec2Failure < RSpecFailure
52
- def initialize(example)
52
+ def initialize(example, formatter)
53
+ @formatter = formatter
53
54
  @example = example
54
55
  @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
55
56
  end
@@ -57,6 +58,17 @@ module CI
57
58
  def failure?
58
59
  exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
59
60
  end
61
+
62
+ def location()
63
+ output = []
64
+ output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
65
+ output.push @exception.message
66
+
67
+ @formatter.format_backtrace(@exception.backtrace, @example).each do |backtrace_info|
68
+ output.push " #{backtrace_info}"
69
+ end
70
+ output.join "\n"
71
+ end
60
72
  end
61
73
 
62
74
  # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
@@ -91,6 +103,10 @@ module CI
91
103
  @formatter.example_group_started(example_group)
92
104
  new_suite(description_for(example_group))
93
105
  end
106
+
107
+ def example_group_finished(example_group)
108
+ @formatter.example_group_finished(example_group)
109
+ end
94
110
 
95
111
  def example_started(name_or_example)
96
112
  @formatter.example_started(name_or_example)
@@ -106,7 +122,7 @@ module CI
106
122
  example_started(name_or_example) if @suite.testcases.empty?
107
123
 
108
124
  if name_or_example.respond_to?(:execution_result) # RSpec 2
109
- failure = RSpec2Failure.new(name_or_example)
125
+ failure = RSpec2Failure.new(name_or_example, @formatter)
110
126
  else
111
127
  failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
112
128
  end
@@ -137,6 +153,10 @@ module CI
137
153
  @formatter.start_dump
138
154
  end
139
155
 
156
+ def dump_failures(*args)
157
+ @formatter.dump_failures(*args)
158
+ end
159
+
140
160
  def dump_failure(*args)
141
161
  @formatter.dump_failure(*args)
142
162
  end
@@ -14,6 +14,7 @@ module CI
14
14
  def self.new(fault)
15
15
  return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
16
16
  return TestUnitSkipped.new(fault) if Test::Unit.constants.include?("Omission") && (fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
17
+ return TestUnitNotification.new(fault) if Test::Unit.constants.include?("Notification") && fault.kind_of?(Test::Unit::Notification)
17
18
  TestUnitError.new(fault)
18
19
  end
19
20
  end
@@ -48,6 +49,16 @@ module CI
48
49
  def location() @fault.location.join("\n") end
49
50
  end
50
51
 
52
+ # Wrapper around a <code>Test::Unit</code> 2.0 notification.
53
+ class TestUnitNotification
54
+ def initialize(fault) @fault = fault end
55
+ def failure?() false end
56
+ def error?() false end
57
+ def name() Test::Unit::Notification.name end
58
+ def message() @fault.message end
59
+ def location() @fault.location.join("\n") end
60
+ end
61
+
51
62
  # Replacement Mediator that adds listeners to capture the results of the <code>Test::Unit</code> runs.
52
63
  class TestUnit < Test::Unit::UI::TestRunnerMediator
53
64
  def initialize(suite, report_mgr = nil)
@@ -1,5 +1,5 @@
1
1
  module CI
2
2
  module Reporter
3
- VERSION = "1.6.4"
3
+ VERSION = "1.6.5"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
1
+ # Copyright (c) 2006-2011 Nick Sieger <nicksieger@gmail.com>
2
2
  # See the file LICENSE.txt included with the distribution for
3
3
  # software license details.
4
4
 
@@ -123,21 +123,23 @@ describe "The RSpec reporter" do
123
123
  @fmt.example_failed("should fail", 1, @error)
124
124
  @fmt.dump_summary(0.1, 1, 0, 0)
125
125
  end
126
-
126
+
127
127
  describe 'RSpec2Failure' do
128
128
  before(:each) do
129
+ @formatter = mock "formatter"
130
+ @formatter.should_receive(:format_backtrace).and_return("backtrace")
129
131
  @rspec20_example = mock('RSpec2.0 Example', :execution_result => {:exception_encountered => StandardError.new('rspec2.0 ftw')})
130
132
  @rspec22_example = mock('RSpec2.2 Example', :execution_result => {:exception => StandardError.new('rspec2.2 ftw')})
131
133
  end
132
134
 
133
135
  it 'should handle rspec (< 2.2) execution results' do
134
- failure = CI::Reporter::RSpec2Failure.new(@rspec20_example)
136
+ failure = CI::Reporter::RSpec2Failure.new(@rspec20_example, @formatter)
135
137
  failure.name.should_not be_nil
136
138
  failure.message.should == 'rspec2.0 ftw'
137
139
  failure.location.should_not be_nil
138
140
  end
139
141
  it 'should handle rspec (>= 2.2) execution results' do
140
- failure = CI::Reporter::RSpec2Failure.new(@rspec22_example)
142
+ failure = CI::Reporter::RSpec2Failure.new(@rspec22_example, @formatter)
141
143
  failure.name.should_not be_nil
142
144
  failure.message.should == 'rspec2.2 ftw'
143
145
  failure.location.should_not be_nil
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_reporter
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 6
8
- - 4
9
- version: 1.6.4
4
+ prerelease:
5
+ version: 1.6.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Nick Sieger
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-12-21 00:00:00 -06:00
13
+ date: 2011-06-14 00:00:00 -05:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 1
31
- - 2
32
24
  version: 2.1.2
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,13 +32,20 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 2
45
- - 0
46
- - 4
47
35
  version: 2.0.4
48
36
  type: :development
49
37
  version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: hoe
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.9.4
47
+ type: :development
48
+ version_requirements: *id003
50
49
  description: CI::Reporter is an add-on to Test::Unit, RSpec and Cucumber that allows you to generate XML reports of your test, spec and/or feature runs. The resulting files can be read by a continuous integration system that understands Ant's JUnit report XML format, thus allowing your CI system to track test/spec successes and failures.
51
50
  email: nick@nicksieger.com
52
51
  executables: []
@@ -106,21 +105,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
105
  requirements:
107
106
  - - ">="
108
107
  - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
108
  version: "0"
112
109
  required_rubygems_version: !ruby/object:Gem::Requirement
113
110
  none: false
114
111
  requirements:
115
112
  - - ">="
116
113
  - !ruby/object:Gem::Version
117
- segments:
118
- - 0
119
114
  version: "0"
120
115
  requirements: []
121
116
 
122
117
  rubyforge_project: caldersphere
123
- rubygems_version: 1.3.7
118
+ rubygems_version: 1.5.1
124
119
  signing_key:
125
120
  specification_version: 3
126
121
  summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.