ci_reporter 1.6.2 → 1.6.3

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,11 @@
1
+ == 1.6.3
2
+
3
+ - Thanks to yairgo and tylerkovacs for their assistance and prodding
4
+ for RSpec 2 support this release.
5
+ - GH #4: Updated for modern Cucumber (0.9.2 as of this writing)
6
+ - GH #6: Capture dynamically-named RSpec examples
7
+ - GH #7: RSpec 2.0.0 compatibility
8
+
1
9
  == 1.6.2
2
10
 
3
11
  - GH #1: Properly escape text in system-out and system-err tags (Matt Kanwisher)
data/Manifest.txt CHANGED
@@ -6,23 +6,24 @@ Rakefile
6
6
  stub.rake
7
7
  lib/ci/reporter/core.rb
8
8
  lib/ci/reporter/cucumber.rb
9
+ lib/ci/reporter/report_manager.rb
10
+ lib/ci/reporter/rspec.rb
11
+ lib/ci/reporter/test_suite.rb
12
+ lib/ci/reporter/test_unit.rb
13
+ lib/ci/reporter/version.rb
9
14
  lib/ci/reporter/rake/cucumber.rb
10
15
  lib/ci/reporter/rake/cucumber_loader.rb
11
16
  lib/ci/reporter/rake/rspec.rb
12
17
  lib/ci/reporter/rake/rspec_loader.rb
13
18
  lib/ci/reporter/rake/test_unit.rb
14
19
  lib/ci/reporter/rake/test_unit_loader.rb
15
- lib/ci/reporter/report_manager.rb
16
- lib/ci/reporter/rspec.rb
17
- lib/ci/reporter/test_suite.rb
18
- lib/ci/reporter/test_unit.rb
19
- lib/ci/reporter/version.rb
20
+ lib/ci/reporter/rake/utils.rb
21
+ spec/spec_helper.rb
20
22
  spec/ci/reporter/cucumber_spec.rb
21
23
  spec/ci/reporter/output_capture_spec.rb
22
- spec/ci/reporter/rake/rake_tasks_spec.rb
23
24
  spec/ci/reporter/report_manager_spec.rb
24
25
  spec/ci/reporter/rspec_spec.rb
25
26
  spec/ci/reporter/test_suite_spec.rb
26
27
  spec/ci/reporter/test_unit_spec.rb
27
- spec/spec_helper.rb
28
+ spec/ci/reporter/rake/rake_tasks_spec.rb
28
29
  tasks/ci_reporter.rake
data/README.txt CHANGED
@@ -1,9 +1,5 @@
1
1
  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.
2
2
 
3
- == Dependencies
4
-
5
- CI::Reporter has one required dependency on Builder, but since many will have a viable version of Builder via Rails' ActiveSupport gem, Builder is not a direct dependency of the project at the moment. Instead, ensure that you have either the +builder+ or +activesupport+ gem installed before continuing. CI::Reporter will raise an exception at runtime if it cannot locate Builder.
6
-
7
3
  == Installation
8
4
 
9
5
  CI::Reporter is available as a gem. To install the gem, use the usual gem command:
@@ -12,12 +8,11 @@ CI::Reporter is available as a gem. To install the gem, use the usual gem comman
12
8
 
13
9
  == Usage
14
10
 
15
- CI::Reporter works best with projects that use a +Rakefile+ along with the standard <code>Rake::TestTask</code> or <code>Spec::Rake::SpecTask</code> tasks for running tests or examples, respectively. In this fashion, it hooks into <code>Test::Unit</code> or +RSpec+ using environment variables recognized by these custom tasks to inject the CI::Reporter code into the test or spec runs. If you're using the Rails plugin, step 1 is unnecessary; skip to step 2.
11
+ CI::Reporter works best with projects that use a +Rakefile+ along with the standard <code>Rake::TestTask</code> or <code>Spec::Rake::SpecTask/RSpec::Core::RakeTask</code> tasks for running tests or examples, respectively. In this fashion, it hooks into <code>Test::Unit</code> or +RSpec+ using environment variables recognized by these custom tasks to inject the CI::Reporter code into the test or spec runs. If you're using the Rails plugin, step 1 is unnecessary; skip to step 2.
16
12
 
17
13
  1. To use CI::Reporter, simply add the following lines to your Rakefile:
18
14
 
19
15
  require 'rubygems'
20
- gem 'ci_reporter'
21
16
  require 'ci/reporter/rake/rspec' # use this if you're using RSpec
22
17
  require 'ci/reporter/rake/cucumber' # use this if you're using Cucumber
23
18
  require 'ci/reporter/rake/test_unit' # use this if you're using Test::Unit
@@ -49,7 +44,7 @@ If for some reason you can't use the above technique to inject CI::Reporter (e.g
49
44
 
50
45
  ruby -r GEM_PATH/lib/ci/reporter/rake/cucumber_loader -S cucumber --format CI::Reporter::Cucumber
51
46
 
52
- There's a bit of a chicken and egg problem because rubygems needs to be loaded before you can require any CI::Reporter files. If you cringe hard-coding a full path to a specific version of the gem, you can also copy the +rspec_loader+ file into your project and require it directly -- the contents are version-agnostic and are not likely to change in future releases.
47
+ There's a bit of a chicken and egg problem because rubygems needs to be loaded before you can require any CI::Reporter files. If you cringe hard-coding a full path to a specific version of the gem, you can also copy the +cucumber_loader+ file into your project and require it directly -- the contents are version-agnostic and are not likely to change in future releases.
53
48
 
54
49
  == Environment Variables
55
50
 
@@ -63,8 +58,8 @@ You can get the CI::Reporter source using Git, in any of the following ways:
63
58
  git clone git://git.caldersphere.net/ci_reporter.git
64
59
  git clone git://github.com/nicksieger/ci_reporter.git
65
60
 
66
- You can also download a tarball of the latest CI::Reporter source at http://github.com/nicksieger/ci_reporter/tree/master.
61
+ You can also download a tarball of the latest CI::Reporter source at http://github.com/nicksieger/ci_reporter/.
67
62
 
68
63
  == License
69
64
 
70
- This software is released under an MIT license. For details, see the LICENSE.txt file included with the distribution. The software is copyright (c) 2006-2007 Nick Sieger <nicksieger@gmail.com>.
65
+ This software is released under an MIT license. For details, see the LICENSE.txt file included with the distribution. The software is copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>.
data/Rakefile CHANGED
@@ -1,6 +1,3 @@
1
- require 'spec/rake/spectask'
2
- require 'spec/rake/verify_rcov'
3
-
4
1
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
5
2
  "*.rake", "lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
6
3
 
@@ -23,6 +20,12 @@ begin
23
20
  end
24
21
  hoe.spec.files = MANIFEST
25
22
  hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
23
+ hoe.spec.rdoc_options += ["-SHN", "-f", "darkfish"]
24
+
25
+ task :gemspec do
26
+ File.open("#{hoe.name}.gemspec", "w") {|f| f << hoe.spec.to_ruby }
27
+ end
28
+ task :package => :gemspec
26
29
  rescue LoadError
27
30
  puts "You really need Hoe installed to be able to package this gem"
28
31
  end
@@ -31,6 +34,7 @@ end
31
34
  # !@#$ no easy way to empty the default list of prerequisites
32
35
  # Leave my tasks alone, Hoe
33
36
  %w(default spec rcov).each do |task|
37
+ next unless Rake::Task.task_defined?(task)
34
38
  Rake::Task[task].prerequisites.clear
35
39
  Rake::Task[task].actions.clear
36
40
  end
@@ -42,21 +46,36 @@ else
42
46
  task :default => :rcov
43
47
  end
44
48
 
45
- Spec::Rake::SpecTask.new do |t|
46
- t.spec_opts = ["--diff", "unified"]
49
+ RSpecTask = begin
50
+ require 'rspec/core/rake_task'
51
+ @spec_bin = 'rspec'
52
+ RSpec::Core::RakeTask
53
+ rescue LoadError
54
+ require 'spec/rake/spectask'
55
+ @spec_bin = 'spec'
56
+ Spec::Rake::SpecTask
57
+ end
58
+
59
+ RSpecTask.new do |t|
47
60
  end
48
61
 
49
- Spec::Rake::SpecTask.new("spec:rcov") do |t|
50
- t.rcov_opts << '--exclude gems/*'
62
+ RSpecTask.new("spec:rcov") do |t|
63
+ t.rcov_opts = ['--exclude gems/*']
51
64
  t.rcov = true
52
65
  end
53
- # so we don't confuse autotest
54
- RCov::VerifyTask.new(:rcov) do |t|
55
- # Can't get threshold up to 100 unless RSpec backwards compatibility
56
- # code is dropped
57
- t.threshold = 98
58
- t.require_exact_threshold = false
66
+
67
+ begin
68
+ require 'spec/rake/verify_rcov'
69
+ # so we don't confuse autotest
70
+ RCov::VerifyTask.new(:rcov) do |t|
71
+ # Can't get threshold up to 100 unless RSpec backwards compatibility
72
+ # code is dropped
73
+ t.threshold = 95
74
+ t.require_exact_threshold = false
75
+ end
76
+ rescue LoadError
59
77
  end
78
+
60
79
  task "spec:rcov" do
61
80
  rm_f "Manifest.txt"
62
81
  end
@@ -66,17 +85,17 @@ task :generate_output do
66
85
  rm_rf "acceptance/reports"
67
86
  ENV['CI_REPORTS'] = "acceptance/reports"
68
87
  begin
69
- `ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
70
- `ruby -Ilib -S spec --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb` rescue nil
71
- `ruby -Ilib -rci/reporter/rake/cucumber_loader -S cucumber --format CI::Reporter::Cucumber acceptance/cucumber` rescue nil
88
+ `ruby -Ilib -rubygems -rci/reporter/rake/test_unit_loader acceptance/test_unit_example_test.rb` rescue puts "Warning: #{$!}"
89
+ `ruby -Ilib -rubygems -S #{@spec_bin} --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb` rescue puts "Warning: #{$!}"
90
+ `ruby -Ilib -rubygems -rci/reporter/rake/cucumber_loader -S cucumber --format CI::Reporter::Cucumber acceptance/cucumber` rescue puts "Warning: #{$!}"
72
91
  ensure
73
92
  ENV.delete 'CI_REPORTS'
74
93
  end
75
94
  end
76
95
  task :acceptance => :generate_output
77
96
 
78
- Spec::Rake::SpecTask.new(:acceptance_spec) do |t|
79
- t.spec_files = FileList['acceptance/verification_spec.rb']
97
+ RSpecTask.new(:acceptance_spec) do |t|
98
+ t.pattern = FileList['acceptance/verification_spec.rb']
80
99
  end
81
100
  task :acceptance => :acceptance_spec
82
101
 
@@ -3,17 +3,10 @@
3
3
  # software license details.
4
4
 
5
5
  require 'ci/reporter/core'
6
- tried_gem = false
6
+ require 'cucumber'
7
7
  begin
8
- require 'cucumber'
9
8
  require 'cucumber/ast/visitor'
10
9
  rescue LoadError
11
- unless tried_gem
12
- tried_gem = true
13
- require 'rubygems'
14
- gem 'cucumber'
15
- retry
16
- end
17
10
  end
18
11
 
19
12
  module CI
@@ -46,53 +39,81 @@ module CI
46
39
  end
47
40
  end
48
41
 
49
- class Cucumber < ::Cucumber::Ast::Visitor
50
-
51
- attr_accessor :test_suite, :report_manager, :feature_name
42
+ class Cucumber
43
+ attr_accessor :report_manager, :test_suite, :name
52
44
 
53
45
  def initialize(step_mother, io, options)
54
- self.report_manager = ReportManager.new("features")
55
- super(step_mother)
46
+ @report_manager = ReportManager.new("features")
56
47
  end
57
48
 
58
- def visit_feature_name(name)
59
- self.feature_name = name.split("\n").first
60
- super
49
+ def before_feature(feature)
50
+ self.test_suite = TestSuite.new(@name)
51
+ test_suite.start
61
52
  end
62
53
 
63
- def visit_feature_element(feature_element)
64
- self.test_suite = TestSuite.new("#{feature_name} #{feature_element.instance_variable_get("@name")}")
65
- test_suite.start
54
+ def after_feature(feature)
55
+ test_suite.name = @name
56
+ test_suite.finish
57
+ report_manager.write_report(@test_suite)
58
+ @test_suite = nil
59
+ end
66
60
 
67
- return_value = super
61
+ def before_background(*args)
62
+ end
68
63
 
69
- test_suite.finish
70
- report_manager.write_report(test_suite)
71
- self.test_suite = nil
64
+ def after_background(*args)
65
+ end
72
66
 
73
- return_value
67
+ def feature_name(keyword, name)
68
+ @name = (name || "Unnamed feature").split("\n").first
74
69
  end
75
70
 
76
- def visit_step(step)
77
- test_case = TestCase.new(step.name)
78
- test_case.start
71
+ def scenario_name(keyword, name, *args)
72
+ @scenario = (name || "Unnamed scenario").split("\n").first
73
+ end
79
74
 
80
- return_value = super
75
+ def before_steps(steps)
76
+ @test_case = TestCase.new(@scenario)
77
+ @test_case.start
78
+ end
81
79
 
82
- test_case.finish
80
+ def after_steps(steps)
81
+ @test_case.finish
83
82
 
84
- case step.status
83
+ case steps.status
85
84
  when :pending, :undefined
86
- test_case.name = "#{test_case.name} (PENDING)"
85
+ @test_case.name = "#{@test_case.name} (PENDING)"
87
86
  when :skipped
88
- test_case.name = "#{test_case.name} (SKIPPED)"
87
+ @test_case.name = "#{@test_case.name} (SKIPPED)"
89
88
  when :failed
90
- test_case.failures << CucumberFailure.new(step)
89
+ @test_case.failures << CucumberFailure.new(steps)
91
90
  end
92
91
 
93
- test_suite.testcases << test_case
92
+ test_suite.testcases << @test_case
93
+ @test_case = nil
94
+ end
94
95
 
95
- return_value
96
+ def before_examples(*args)
97
+ @header_row = true
98
+ end
99
+
100
+ def after_examples(*args)
101
+ end
102
+
103
+ def before_table_row(table_row)
104
+ @test_case = TestCase.new("#@scenario (outline: #{table_row.name})")
105
+ @test_case.start
106
+ end
107
+
108
+ def after_table_row(table_row)
109
+ if @header_row
110
+ @header_row = false
111
+ return
112
+ end
113
+ @test_case.finish
114
+ @test_case.failures << CucumberFailure.new(table_row) if table_row.failed?
115
+ test_suite.testcases << @test_case
116
+ @test_case = nil
96
117
  end
97
118
  end
98
119
  end
@@ -2,6 +2,8 @@
2
2
  # See the file LICENSE.txt included with the distribution for
3
3
  # software license details.
4
4
 
5
+ require File.expand_path('../utils', __FILE__)
6
+
5
7
  namespace :ci do
6
8
  namespace :setup do
7
9
  task :cucumber_report_cleanup do
@@ -9,9 +11,9 @@ namespace :ci do
9
11
  end
10
12
 
11
13
  task :cucumber => :cucumber_report_cleanup do
12
- spec_opts = ["--require", "#{File.dirname(__FILE__)}/cucumber_loader.rb",
14
+ cuke_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/cucumber_loader.rb"),
13
15
  "--format", "CI::Reporter::Cucumber"].join(" ")
14
- ENV["CUCUMBER_OPTS"] = "#{ENV['CUCUMBER_OPTS']} #{spec_opts}"
16
+ ENV["CUCUMBER_OPTS"] = "#{ENV['CUCUMBER_OPTS']} #{cuke_opts}"
15
17
  end
16
18
  end
17
19
  end
@@ -2,6 +2,8 @@
2
2
  # See the file LICENSE.txt included with the distribution for
3
3
  # software license details.
4
4
 
5
+ require File.expand_path('../utils', __FILE__)
6
+
5
7
  namespace :ci do
6
8
  namespace :setup do
7
9
  task :spec_report_cleanup do
@@ -9,13 +11,13 @@ namespace :ci do
9
11
  end
10
12
 
11
13
  task :rspec => :spec_report_cleanup do
12
- spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
14
+ spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"),
13
15
  "--format", "CI::Reporter::RSpec"].join(" ")
14
16
  ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
15
17
  end
16
18
 
17
19
  task :rspecdoc => :spec_report_cleanup do
18
- spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
20
+ spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"),
19
21
  "--format", "CI::Reporter::RSpecDoc"].join(" ")
20
22
  ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
21
23
  end
@@ -2,11 +2,14 @@
2
2
  # See the file LICENSE.txt included with the distribution for
3
3
  # software license details.
4
4
 
5
+ require File.expand_path('../utils', __FILE__)
6
+
5
7
  namespace :ci do
6
8
  namespace :setup do
7
9
  task :testunit do
8
10
  rm_rf ENV["CI_REPORTS"] || "test/reports"
9
- ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{File.dirname(__FILE__)}/test_unit_loader.rb"
11
+ test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/test_unit_loader.rb"
12
+ ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}"
10
13
  end
11
14
  end
12
15
  end
@@ -0,0 +1,14 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ module CI
6
+ module Reporter
7
+ def self.maybe_quote_filename(fn)
8
+ if fn =~ /\s/
9
+ fn = %{"#{fn}"}
10
+ end
11
+ fn
12
+ end
13
+ end
14
+ end
@@ -3,26 +3,36 @@
3
3
  # software license details.
4
4
 
5
5
  require 'ci/reporter/core'
6
- tried_gem = false
7
- begin
8
- require 'spec'
9
- require 'spec/runner/formatter/progress_bar_formatter'
10
- require 'spec/runner/formatter/specdoc_formatter'
11
- rescue LoadError
12
- unless tried_gem
13
- tried_gem = true
14
- require 'rubygems'
15
- gem 'rspec'
16
- retry
17
- end
18
- end
19
6
 
20
7
  module CI
21
8
  module Reporter
9
+ module RSpecFormatters
10
+ begin
11
+ require 'rspec/core/formatters/base_formatter'
12
+ require 'rspec/core/formatters/progress_formatter'
13
+ require 'rspec/core/formatters/documentation_formatter'
14
+ BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter
15
+ ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter
16
+ DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter
17
+ rescue LoadError => first_error
18
+ begin
19
+ require 'spec/runner/formatter/progress_bar_formatter'
20
+ require 'spec/runner/formatter/specdoc_formatter'
21
+ BaseFormatter = ::Spec::Runner::Formatter::BaseFormatter
22
+ ProgressFormatter = ::Spec::Runner::Formatter::ProgressBarFormatter
23
+ DocFormatter = ::Spec::Runner::Formatter::SpecdocFormatter
24
+ rescue LoadError
25
+ raise first_error
26
+ end
27
+ end
28
+ end
29
+
22
30
  # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
23
31
  class RSpecFailure
32
+ attr_reader :exception
24
33
  def initialize(failure)
25
34
  @failure = failure
35
+ @exception = failure.exception
26
36
  end
27
37
 
28
38
  def failure?
@@ -30,21 +40,32 @@ module CI
30
40
  end
31
41
 
32
42
  def error?
33
- !@failure.expectation_not_met?
43
+ !failure?
44
+ end
45
+
46
+ def name() exception.class.name end
47
+ def message() exception.message end
48
+ def location() (exception.backtrace || ["No backtrace available"]).join("\n") end
49
+ end
50
+
51
+ class RSpec2Failure < RSpecFailure
52
+ def initialize(example)
53
+ @example = example
54
+ @exception = @example.execution_result[:exception_encountered]
34
55
  end
35
56
 
36
- def name() @failure.exception.class.name end
37
- def message() @failure.exception.message end
38
- def location() @failure.exception.backtrace.join("\n") end
57
+ def failure?
58
+ exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
59
+ end
39
60
  end
40
61
 
41
62
  # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
42
- class RSpec < Spec::Runner::Formatter::BaseFormatter
63
+ class RSpec < RSpecFormatters::BaseFormatter
43
64
  attr_accessor :report_manager
44
65
  attr_accessor :formatter
45
66
  def initialize(*args)
46
67
  super
47
- @formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
68
+ @formatter ||= RSpecFormatters::ProgressFormatter.new(*args)
48
69
  @report_manager = ReportManager.new("spec")
49
70
  @suite = nil
50
71
  end
@@ -62,45 +83,53 @@ module CI
62
83
  # Compatibility with rspec < 1.2.4
63
84
  def add_example_group(example_group)
64
85
  @formatter.add_example_group(example_group)
65
- new_suite(example_group.description)
86
+ new_suite(description_for(example_group))
66
87
  end
67
88
 
68
89
  # rspec >= 1.2.4
69
90
  def example_group_started(example_group)
70
91
  @formatter.example_group_started(example_group)
71
- new_suite(example_group.description)
92
+ new_suite(description_for(example_group))
72
93
  end
73
94
 
74
- def example_started(name)
75
- @formatter.example_started(name)
76
- name = name.description if name.respond_to?(:description)
77
- spec = TestCase.new name
95
+ def example_started(name_or_example)
96
+ @formatter.example_started(name_or_example)
97
+ spec = TestCase.new
78
98
  @suite.testcases << spec
79
99
  spec.start
80
100
  end
81
101
 
82
- def example_failed(name, counter, failure)
83
- @formatter.example_failed(name, counter, failure)
102
+ def example_failed(name_or_example, *rest)
103
+ @formatter.example_failed(name_or_example, *rest)
104
+
84
105
  # In case we fail in before(:all)
85
- if @suite.testcases.empty?
86
- example_started(name)
106
+ example_started(name_or_example) if @suite.testcases.empty?
107
+
108
+ if name_or_example.respond_to?(:execution_result) # RSpec 2
109
+ failure = RSpec2Failure.new(name_or_example)
110
+ else
111
+ failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
87
112
  end
113
+
88
114
  spec = @suite.testcases.last
89
115
  spec.finish
90
- spec.failures << RSpecFailure.new(failure)
116
+ spec.name = description_for(name_or_example)
117
+ spec.failures << failure
91
118
  end
92
119
 
93
- def example_passed(name)
94
- @formatter.example_passed(name)
120
+ def example_passed(name_or_example)
121
+ @formatter.example_passed(name_or_example)
95
122
  spec = @suite.testcases.last
96
123
  spec.finish
124
+ spec.name = description_for(name_or_example)
97
125
  end
98
126
 
99
127
  def example_pending(*args)
100
128
  @formatter.example_pending(*args)
129
+ name = description_for(args[0])
101
130
  spec = @suite.testcases.last
102
131
  spec.finish
103
- spec.name = "#{spec.name} (PENDING)"
132
+ spec.name = "#{name} (PENDING)"
104
133
  spec.skipped = true
105
134
  end
106
135
 
@@ -126,6 +155,18 @@ module CI
126
155
  end
127
156
 
128
157
  private
158
+ def description_for(name_or_example)
159
+ if name_or_example.respond_to?(:full_description)
160
+ name_or_example.full_description
161
+ elsif name_or_example.respond_to?(:metadata)
162
+ name_or_example.metadata[:example_group][:full_description]
163
+ elsif name_or_example.respond_to?(:description)
164
+ name_or_example.description
165
+ else
166
+ "UNKNOWN"
167
+ end
168
+ end
169
+
129
170
  def write_report
130
171
  @suite.finish
131
172
  @report_manager.write_report(@suite)
@@ -140,7 +181,7 @@ module CI
140
181
 
141
182
  class RSpecDoc < RSpec
142
183
  def initialize(*args)
143
- @formatter = Spec::Runner::Formatter::SpecdocFormatter.new(*args)
184
+ @formatter = RSpecFormatters::DocFormatter.new(*args)
144
185
  super
145
186
  end
146
187
  end
@@ -66,12 +66,6 @@ module CI
66
66
 
67
67
  # Creates the xml builder instance used to create the report xml document.
68
68
  def create_builder
69
- begin
70
- require 'rubygems'
71
- gem 'builder'
72
- rescue LoadError
73
- end
74
-
75
69
  require 'builder'
76
70
  # :escape_attrs is obsolete in a newer version, but should do no harm
77
71
  Builder::XmlMarkup.new(:indent => 2, :escape_attrs => true)
@@ -1,5 +1,5 @@
1
1
  module CI
2
2
  module Reporter
3
- VERSION = "1.6.2"
3
+ VERSION = "1.6.3"
4
4
  end
5
5
  end
@@ -73,54 +73,69 @@ describe "The Cucumber reporter" do
73
73
 
74
74
  it "should record the feature name when a new feature is visited" do
75
75
  cucumber = new_instance
76
- cucumber.visit_feature_name("Some feature name")
77
- cucumber.feature_name.should == "Some feature name"
76
+ cucumber.feature_name(nil, "Some feature name")
77
+ cucumber.name.should == "Some feature name"
78
78
  end
79
79
 
80
80
  it "should record only the first line of a feature name" do
81
81
  cucumber = new_instance
82
- cucumber.visit_feature_name("Some feature name\nLonger description")
83
- cucumber.feature_name.should == "Some feature name"
82
+ cucumber.feature_name(nil, "Some feature name\nLonger description")
83
+ cucumber.name.should == "Some feature name"
84
84
  end
85
85
 
86
- describe "when visiting a new scenario" do
86
+ context "applied to a feature" do
87
87
  before(:each) do
88
88
  @cucumber = new_instance
89
- @cucumber.visit_feature_name("Demo feature")
89
+ @cucumber.feature_name(nil, "Demo feature")
90
90
 
91
- @test_suite = mock("test_suite", :start => nil, :finish => nil)
91
+ @test_suite = mock("test_suite", :start => nil, :finish => nil, :name= => nil)
92
92
  CI::Reporter::TestSuite.stub!(:new).and_return(@test_suite)
93
93
 
94
- @feature_element = mock("feature_element", :accept => true)
94
+ @feature = mock("feature")
95
95
 
96
96
  @report_manager.stub!(:write_report)
97
97
  end
98
98
 
99
- it "should create a new test suite" do
100
- # FIXME: @name is feature_element purely as a by-product of the
101
- # mocking framework implementation. But then again, using
102
- # +instance_variable_get+ in the first place is a bit icky.
103
- CI::Reporter::TestSuite.should_receive(:new).with("Demo feature feature_element")
104
- @cucumber.visit_feature_element(@feature_element)
105
- end
99
+ context "before" do
100
+ it "should create a new test suite" do
101
+ CI::Reporter::TestSuite.should_receive(:new).with(/Demo feature/)
102
+ @cucumber.before_feature(@feature)
103
+ end
106
104
 
107
- it "should indicate that the test suite has started" do
108
- @test_suite.should_receive(:start)
109
- @cucumber.visit_feature_element(@feature_element)
105
+ it "should indicate that the test suite has started" do
106
+ @test_suite.should_receive(:start)
107
+ @cucumber.before_feature(@feature)
108
+ end
110
109
  end
111
110
 
112
- it "should indicate that the test suite has finished" do
113
- @test_suite.should_receive(:finish)
114
- @cucumber.visit_feature_element(@feature_element)
115
- end
111
+ context "after" do
112
+ before :each do
113
+ @cucumber = new_instance
114
+ @cucumber.feature_name(nil, "Demo feature")
115
+
116
+ @test_suite = mock("test_suite", :start => nil, :finish => nil, :name= => nil)
117
+ CI::Reporter::TestSuite.stub!(:new).and_return(@test_suite)
118
+
119
+ @feature = mock("feature")
120
+
121
+ @report_manager.stub!(:write_report)
116
122
 
117
- it "should ask the report manager to write a report" do
118
- @report_manager.should_receive(:write_report).with(@test_suite)
119
- @cucumber.visit_feature_element(@feature_element)
123
+ @cucumber.before_feature(@feature)
124
+ end
125
+
126
+ it "should indicate that the test suite has finished" do
127
+ @test_suite.should_receive(:finish)
128
+ @cucumber.after_feature(@feature)
129
+ end
130
+
131
+ it "should ask the report manager to write a report" do
132
+ @report_manager.should_receive(:write_report).with(@test_suite)
133
+ @cucumber.after_feature(@feature)
134
+ end
120
135
  end
121
136
  end
122
137
 
123
- describe "when visiting a step inside a scenario" do
138
+ context "inside a scenario" do
124
139
  before(:each) do
125
140
  @testcases = []
126
141
 
@@ -132,48 +147,57 @@ describe "The Cucumber reporter" do
132
147
  @test_case = mock("test_case", :start => nil, :finish => nil, :name => "Step Name")
133
148
  CI::Reporter::TestCase.stub!(:new).and_return(@test_case)
134
149
 
135
- @step = mock("step", :accept => true, :status => :passed)
150
+ @step = mock("step", :status => :passed)
136
151
  @step.stub!(:name).and_return("Step Name")
137
152
  end
138
153
 
139
- it "should create a new test case" do
140
- CI::Reporter::TestCase.should_receive(:new).with("Step Name")
141
- @cucumber.visit_step(@step)
142
- end
154
+ context "before steps" do
155
+ it "should create a new test case" do
156
+ CI::Reporter::TestCase.should_receive(:new).with("Step Name")
157
+ @cucumber.scenario_name(nil, "Step Name")
158
+ @cucumber.before_steps(@step)
159
+ end
143
160
 
144
- it "should indicate that the test case has started" do
145
- @test_case.should_receive(:start)
146
- @cucumber.visit_step(@step)
161
+ it "should indicate that the test case has started" do
162
+ @test_case.should_receive(:start)
163
+ @cucumber.before_steps(@step)
164
+ end
147
165
  end
148
166
 
149
- it "should indicate that the test case has finished" do
150
- @test_case.should_receive(:finish)
151
- @cucumber.visit_step(@step)
152
- end
167
+ context "after steps" do
168
+ before :each do
169
+ @cucumber.before_steps(@step)
170
+ end
153
171
 
154
- it "should add the test case to the suite's list of cases" do
155
- @testcases.should be_empty
156
- @cucumber.visit_step(@step)
157
- @testcases.should_not be_empty
158
- @testcases.first.should == @test_case
159
- end
172
+ it "should indicate that the test case has finished" do
173
+ @test_case.should_receive(:finish)
174
+ @cucumber.after_steps(@step)
175
+ end
160
176
 
161
- it "should alter the name of a test case that is pending to include '(PENDING)'" do
162
- @step.stub!(:status).and_return(:pending)
163
- @test_case.should_receive(:name=).with("Step Name (PENDING)")
164
- @cucumber.visit_step(@step)
165
- end
177
+ it "should add the test case to the suite's list of cases" do
178
+ @testcases.should be_empty
179
+ @cucumber.after_steps(@step)
180
+ @testcases.should_not be_empty
181
+ @testcases.first.should == @test_case
182
+ end
166
183
 
167
- it "should alter the name of a test case that is undefined to include '(PENDING)'" do
168
- @step.stub!(:status).and_return(:undefined)
169
- @test_case.should_receive(:name=).with("Step Name (PENDING)")
170
- @cucumber.visit_step(@step)
171
- end
184
+ it "should alter the name of a test case that is pending to include '(PENDING)'" do
185
+ @step.stub!(:status).and_return(:pending)
186
+ @test_case.should_receive(:name=).with("Step Name (PENDING)")
187
+ @cucumber.after_steps(@step)
188
+ end
189
+
190
+ it "should alter the name of a test case that is undefined to include '(PENDING)'" do
191
+ @step.stub!(:status).and_return(:undefined)
192
+ @test_case.should_receive(:name=).with("Step Name (PENDING)")
193
+ @cucumber.after_steps(@step)
194
+ end
172
195
 
173
- it "should alter the name of a test case that was skipped to include '(SKIPPED)'" do
174
- @step.stub!(:status).and_return(:skipped)
175
- @test_case.should_receive(:name=).with("Step Name (SKIPPED)")
176
- @cucumber.visit_step(@step)
196
+ it "should alter the name of a test case that was skipped to include '(SKIPPED)'" do
197
+ @step.stub!(:status).and_return(:skipped)
198
+ @test_case.should_receive(:name=).with("Step Name (SKIPPED)")
199
+ @cucumber.after_steps(@step)
200
+ end
177
201
  end
178
202
 
179
203
  describe "that fails" do
@@ -183,18 +207,20 @@ describe "The Cucumber reporter" do
183
207
  @failures = []
184
208
  @test_case.stub!(:failures).and_return(@failures)
185
209
 
210
+ @cucumber.before_steps(@step)
211
+
186
212
  @cucumber_failure = mock("cucumber_failure")
187
213
  CI::Reporter::CucumberFailure.stub!(:new).and_return(@cucumber_failure)
188
214
  end
189
215
 
190
216
  it "should create a new cucumber failure with that step" do
191
217
  CI::Reporter::CucumberFailure.should_receive(:new).with(@step)
192
- @cucumber.visit_step(@step)
218
+ @cucumber.after_steps(@step)
193
219
  end
194
220
 
195
221
  it "should add the failure to the suite's list of failures" do
196
222
  @failures.should be_empty
197
- @cucumber.visit_step(@step)
223
+ @cucumber.after_steps(@step)
198
224
  @failures.should_not be_empty
199
225
  @failures.first.should == @cucumber_failure
200
226
  end
@@ -10,10 +10,11 @@ describe "The RSpec reporter" do
10
10
  @error = mock("error")
11
11
  @error.stub!(:expectation_not_met?).and_return(false)
12
12
  @error.stub!(:pending_fixed?).and_return(false)
13
+ @error.stub!(:exception).and_return(StandardError.new)
13
14
  @report_mgr = mock("report manager")
14
15
  @options = mock("options")
15
16
  @args = [@options, StringIO.new("")]
16
- @args.shift if Spec::VERSION::MAJOR == 1 && Spec::VERSION::MINOR < 1
17
+ @args.shift unless defined?(::Spec) && ::Spec::VERSION::MAJOR == 1 && ::Spec::VERSION::MINOR >= 1
17
18
  @fmt = CI::Reporter::RSpec.new *@args
18
19
  @fmt.report_manager = @report_mgr
19
20
  @formatter = mock("formatter")
@@ -22,12 +23,12 @@ describe "The RSpec reporter" do
22
23
 
23
24
  it "should use a progress bar formatter by default" do
24
25
  fmt = CI::Reporter::RSpec.new *@args
25
- fmt.formatter.should be_instance_of(Spec::Runner::Formatter::ProgressBarFormatter)
26
+ fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::ProgressFormatter)
26
27
  end
27
28
 
28
29
  it "should use a specdoc formatter for RSpecDoc" do
29
30
  fmt = CI::Reporter::RSpecDoc.new *@args
30
- fmt.formatter.should be_instance_of(Spec::Runner::Formatter::SpecdocFormatter)
31
+ fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::DocFormatter)
31
32
  end
32
33
 
33
34
  it "should create a test suite with one success, one failure, and one pending" do
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,11 @@
3
3
  # software license details.
4
4
 
5
5
  require 'rubygems'
6
- gem 'rspec'
7
- require 'spec'
6
+ begin
7
+ require 'rspec'
8
+ rescue LoadError
9
+ require 'spec'
10
+ end
8
11
 
9
12
  unless defined?(CI_REPORTER_LIB)
10
13
  CI_REPORTER_LIB = File.expand_path(File.dirname(__FILE__) + "/../lib")
metadata CHANGED
@@ -3,34 +3,50 @@ name: ci_reporter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
- - 1
7
- - 6
8
- - 2
9
- version: 1.6.2
6
+ - 1
7
+ - 6
8
+ - 3
9
+ version: 1.6.3
10
10
  platform: ruby
11
11
  authors:
12
- - Nick Sieger
12
+ - Nick Sieger
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-26 00:00:00 -05:00
17
+ date: 2010-10-12 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: builder
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 2
29
- - 1
30
- - 2
31
- version: 2.1.2
32
- type: :runtime
33
- version_requirements: *id001
20
+ - !ruby/object:Gem::Dependency
21
+ name: builder
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 1
31
+ - 2
32
+ version: 2.1.2
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rubyforge
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 0
46
+ - 4
47
+ version: 2.0.4
48
+ type: :development
49
+ version_requirements: *id002
34
50
  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.
35
51
  email: nick@nicksieger.com
36
52
  executables: []
@@ -38,75 +54,81 @@ executables: []
38
54
  extensions: []
39
55
 
40
56
  extra_rdoc_files:
41
- - History.txt
42
- - Manifest.txt
43
- - README.txt
44
- - LICENSE.txt
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ - LICENSE.txt
45
61
  files:
46
- - History.txt
47
- - Manifest.txt
48
- - README.txt
49
- - LICENSE.txt
50
- - Rakefile
51
- - stub.rake
52
- - lib/ci/reporter/core.rb
53
- - lib/ci/reporter/cucumber.rb
54
- - lib/ci/reporter/rake/cucumber.rb
55
- - lib/ci/reporter/rake/cucumber_loader.rb
56
- - lib/ci/reporter/rake/rspec.rb
57
- - lib/ci/reporter/rake/rspec_loader.rb
58
- - lib/ci/reporter/rake/test_unit.rb
59
- - lib/ci/reporter/rake/test_unit_loader.rb
60
- - lib/ci/reporter/report_manager.rb
61
- - lib/ci/reporter/rspec.rb
62
- - lib/ci/reporter/test_suite.rb
63
- - lib/ci/reporter/test_unit.rb
64
- - lib/ci/reporter/version.rb
65
- - spec/ci/reporter/cucumber_spec.rb
66
- - spec/ci/reporter/output_capture_spec.rb
67
- - spec/ci/reporter/rake/rake_tasks_spec.rb
68
- - spec/ci/reporter/report_manager_spec.rb
69
- - spec/ci/reporter/rspec_spec.rb
70
- - spec/ci/reporter/test_suite_spec.rb
71
- - spec/ci/reporter/test_unit_spec.rb
72
- - spec/spec_helper.rb
73
- - tasks/ci_reporter.rake
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.txt
65
+ - LICENSE.txt
66
+ - Rakefile
67
+ - stub.rake
68
+ - lib/ci/reporter/core.rb
69
+ - lib/ci/reporter/cucumber.rb
70
+ - lib/ci/reporter/report_manager.rb
71
+ - lib/ci/reporter/rspec.rb
72
+ - lib/ci/reporter/test_suite.rb
73
+ - lib/ci/reporter/test_unit.rb
74
+ - lib/ci/reporter/version.rb
75
+ - lib/ci/reporter/rake/cucumber.rb
76
+ - lib/ci/reporter/rake/cucumber_loader.rb
77
+ - lib/ci/reporter/rake/rspec.rb
78
+ - lib/ci/reporter/rake/rspec_loader.rb
79
+ - lib/ci/reporter/rake/test_unit.rb
80
+ - lib/ci/reporter/rake/test_unit_loader.rb
81
+ - lib/ci/reporter/rake/utils.rb
82
+ - spec/spec_helper.rb
83
+ - spec/ci/reporter/cucumber_spec.rb
84
+ - spec/ci/reporter/output_capture_spec.rb
85
+ - spec/ci/reporter/report_manager_spec.rb
86
+ - spec/ci/reporter/rspec_spec.rb
87
+ - spec/ci/reporter/test_suite_spec.rb
88
+ - spec/ci/reporter/test_unit_spec.rb
89
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
90
+ - tasks/ci_reporter.rake
74
91
  has_rdoc: true
75
92
  homepage: http://caldersphere.rubyforge.org/ci_reporter
76
93
  licenses: []
77
94
 
78
95
  post_install_message:
79
96
  rdoc_options:
80
- - --main
81
- - README.txt
97
+ - --main
98
+ - README.txt
99
+ - -SHN
100
+ - -f
101
+ - darkfish
82
102
  require_paths:
83
- - lib
103
+ - lib
84
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
85
106
  requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- segments:
89
- - 0
90
- version: "0"
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
111
+ version: "0"
91
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
92
114
  requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- segments:
96
- - 0
97
- version: "0"
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
119
+ version: "0"
98
120
  requirements: []
99
121
 
100
122
  rubyforge_project: caldersphere
101
- rubygems_version: 1.3.6
123
+ rubygems_version: 1.3.7
102
124
  signing_key:
103
125
  specification_version: 3
104
126
  summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
105
127
  test_files:
106
- - spec/ci/reporter/cucumber_spec.rb
107
- - spec/ci/reporter/output_capture_spec.rb
108
- - spec/ci/reporter/rake/rake_tasks_spec.rb
109
- - spec/ci/reporter/report_manager_spec.rb
110
- - spec/ci/reporter/rspec_spec.rb
111
- - spec/ci/reporter/test_suite_spec.rb
112
- - spec/ci/reporter/test_unit_spec.rb
128
+ - spec/ci/reporter/cucumber_spec.rb
129
+ - spec/ci/reporter/output_capture_spec.rb
130
+ - spec/ci/reporter/report_manager_spec.rb
131
+ - spec/ci/reporter/rspec_spec.rb
132
+ - spec/ci/reporter/test_suite_spec.rb
133
+ - spec/ci/reporter/test_unit_spec.rb
134
+ - spec/ci/reporter/rake/rake_tasks_spec.rb