Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tagging 1.5.1

git-svn-id: http://svn.caldersphere.net/svn/main/rubyforge/ci_reporter/tags/1.5.1@196 b03c2d0b-2f10-0410-a2f9-fc8001506dfa
  • Loading branch information...
commit 28d371d5b2ee3d5fee280ab063807c7f527249e6 1 parent f13ed9f
@nicksieger nicksieger authored
View
12 History.txt
@@ -1,3 +1,15 @@
+== 1.5.1
+
+- Fix silly load-path error that some had been seeing
+
+== 1.5
+
+- Support for RSpec 1.1.1 example groups (which broke ci_reporter 1.4)
+- Change internal model to delegation instead of inheritance, allowing ci_reporter to wrap different output formatters
+- Add 'ci:setup:rspecdoc' task to output specdoc format instead of progress
+- Add support for pending examples; they will be listed in the report XML as successful, but the name will have a '(PENDING)' tag appended
+- Support for RSpec < 0.9 removed as promised; use 1.4 if you still need to use an older version of RSpec
+
== 1.4
- Test::Unit tests that fail in multiple places (setup, test method, and teardown) are now tracked (marcog)
View
13 Rakefile
@@ -30,11 +30,15 @@ end
# !@#$ no easy way to empty the default list of prerequisites
Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
-task :default => :rcov
+# No RCov on JRuby at the moment
+if RUBY_PLATFORM =~ /java/
+ task :default => :spec
+else
+ task :default => :rcov
+end
Spec::Rake::SpecTask.new do |t|
- t.spec_opts ||= []
- t.spec_opts << "--diff" << "unified"
+ t.spec_opts = ["--diff", "unified"]
end
Spec::Rake::SpecTask.new("spec:rcov") do |t|
@@ -44,7 +48,7 @@ end
RCov::VerifyTask.new(:rcov) do |t|
# Can't get threshold up to 100 until the RSpec < 1.0 compatibility
# code is dropped
- t.threshold = 97
+ t.threshold = 99
t.require_exact_threshold = false
end
task "spec:rcov" do
@@ -53,6 +57,7 @@ end
task :rcov => "spec:rcov"
task :generate_output do
+ rm_f "acceptance/reports/*.xml"
ENV['CI_REPORTS'] = "acceptance/reports"
begin
`ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
View
8 acceptance/rspec_example_spec.rb
@@ -7,4 +7,12 @@
it "should fail" do
violated
end
+
+ it "should be pending"
+
+ describe "nested" do
+ it "should succeed" do
+ true.should be_true
+ end
+ end
end
View
17 acceptance/verification_spec.rb
@@ -34,8 +34,9 @@
end
describe "RSpec acceptance" do
- it "should generate one XML file" do
+ it "should generate two XML files" do
File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')).should == true
+ File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')).should == true
end
it "should have two tests and one failure" do
@@ -44,10 +45,20 @@
end
doc.root.attributes["errors"].should == "0"
doc.root.attributes["failures"].should == "1"
- doc.root.attributes["tests"].should == "2"
- doc.root.elements.to_a("/testsuite/testcase").size.should == 2
+ doc.root.attributes["tests"].should == "3"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 3
failures = doc.root.elements.to_a("/testsuite/testcase/failure")
failures.size.should == 1
failures.first.attributes["type"].should == "Spec::Expectations::ExpectationNotMetError"
end
+
+ it "should have one test in the nested example report" do
+ doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "0"
+ doc.root.attributes["failures"].should == "0"
+ doc.root.attributes["tests"].should == "1"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
+ end
end
View
13 lib/ci/reporter/rake/rspec.rb
@@ -4,13 +4,20 @@
namespace :ci do
namespace :setup do
- task :rspec do
+ task :spec_report_cleanup do
rm_rf ENV["CI_REPORTS"] || "spec/reports"
+ end
+
+ task :rspec => :spec_report_cleanup do
spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
"--format", "CI::Reporter::RSpec"].join(" ")
ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
- # Pre RSpec 1.0.6
- ENV["RSPECOPTS"] = "#{ENV['RSPECOPTS']} #{spec_opts}"
+ end
+
+ task :rspecdoc => :spec_report_cleanup do
+ spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
+ "--format", "CI::Reporter::RSpecDoc"].join(" ")
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
end
end
end
View
2  lib/ci/reporter/rake/rspec_loader.rb
@@ -2,5 +2,5 @@
# See the file LICENSE.txt included with the distribution for
# software license details.
-$: << File.dirname(__FILE__) + "/../../../lib"
+$: << File.dirname(__FILE__) + "/../../.."
require 'ci/reporter/rspec'
View
2  lib/ci/reporter/rake/test_unit_loader.rb
@@ -2,7 +2,7 @@
# See the file LICENSE.txt included with the distribution for
# software license details.
-$: << File.dirname(__FILE__) + "/../../../lib"
+$: << File.dirname(__FILE__) + "/../../.."
require 'ci/reporter/test_unit'
module Test #:nodoc:all
View
143 lib/ci/reporter/rspec.rb
@@ -3,13 +3,19 @@
# software license details.
require 'ci/reporter/core'
+tried_gem = false
begin
- gem 'rspec'
-rescue Gem::LoadError
- # Needed for non-gem RSpec (e.g., reporting on RSpec's own specs);
- # if spec isn't found, the next require will blow up
+ require 'spec'
+ require 'spec/runner/formatter/progress_bar_formatter'
+ require 'spec/runner/formatter/specdoc_formatter'
+rescue LoadError
+ unless tried_gem
+ tried_gem = true
+ require 'rubygems'
+ gem 'rspec'
+ retry
+ end
end
-require 'spec'
module CI
module Reporter
@@ -33,101 +39,78 @@ def location() @failure.exception.backtrace.join("\n") end
end
# Custom +RSpec+ formatter used to hook into the spec runs and capture results.
- class RSpec < Spec::Runner::Formatter::ProgressBarFormatter
- def initialize(output, dry_run=false, colour=false, report_mgr=nil)
- if respond_to? :dry_run=
- super(output)
- self.dry_run=dry_run
- self.colour=colour
- else
- super(output, dry_run, colour)
- end
- @report_manager = report_mgr || ReportManager.new("spec")
+ class RSpec < Spec::Runner::Formatter::BaseFormatter
+ attr_accessor :report_manager
+ attr_accessor :formatter
+ def initialize(*args)
+ super
+ @formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
+ @report_manager = ReportManager.new("spec")
@suite = nil
end
- def deprecated
- unless @warned
- require 'ci/reporter/version'
- warn "warning: use of RSpec < 0.9 with CI::Reporter #{CI::Reporter::VERSION} is deprecated;"
- warn "a future version will not be compatible."
- end
- @warned = true
- end
-
def start(spec_count)
- super
+ @formatter.start(spec_count)
end
- # Pre-0.9 hook
- def add_context(name, first)
- super
- deprecated
- new_suite(name)
- end
-
- # Post-0.9 hook
def add_behaviour(name)
- super
+ @formatter.add_behaviour(name)
new_suite(name)
end
- # Pre-0.9 hook
- def spec_started(name)
- super
- deprecated
- case_started(name)
+ def add_example_group(example_group)
+ @formatter.add_example_group(example_group)
+ new_suite(example_group.description)
end
- # Post-0.9 hook
def example_started(name)
- super
- case_started(name)
- end
-
- # Pre-0.9 hook
- def spec_failed(name, counter, failure)
- super
- deprecated
- case_failed(name, counter, failure)
+ @formatter.example_started(name)
+ spec = TestCase.new name
+ @suite.testcases << spec
+ spec.start
end
- # Post-0.9 hook
def example_failed(name, counter, failure)
- super
- case_failed(name, counter, failure)
+ @formatter.example_failed(name, counter, failure)
+ spec = @suite.testcases.last
+ spec.finish
+ spec.failures << RSpecFailure.new(failure)
end
- # Pre-0.9 hook
- def spec_passed(name)
- super
- deprecated
- case_passed(name)
+ def example_passed(name)
+ @formatter.example_passed(name)
+ spec = @suite.testcases.last
+ spec.finish
end
- # Post-0.9 hook
- def example_passed(name)
- super
- case_passed(name)
+ def example_pending(*args)
+ @formatter.example_pending(*args)
+ spec = @suite.testcases.last
+ spec.finish
+ spec.name = "#{spec.name} (PENDING)"
end
def start_dump
- super
+ @formatter.start_dump
end
- def dump_failure(counter, failure)
- super
+ def dump_failure(*args)
+ @formatter.dump_failure(*args)
end
- def dump_summary(duration, example_count, failure_count, not_implemented_count = 0)
- begin
- super
- rescue ArgumentError
- super(duration, example_count, failure_count)
- end
+ def dump_summary(*args)
+ @formatter.dump_summary(*args)
write_report
end
+ def dump_pending
+ @formatter.dump_pending
+ end
+
+ def close
+ @formatter.close
+ end
+
private
def write_report
@suite.finish
@@ -139,22 +122,12 @@ def new_suite(name)
@suite = TestSuite.new name
@suite.start
end
+ end
- def case_started(name)
- spec = TestCase.new name
- @suite.testcases << spec
- spec.start
- end
-
- def case_failed(name, counter, failure)
- spec = @suite.testcases.last
- spec.finish
- spec.failures << RSpecFailure.new(failure)
- end
-
- def case_passed(name)
- spec = @suite.testcases.last
- spec.finish
+ class RSpecDoc < RSpec
+ def initialize(*args)
+ @formatter = Spec::Runner::Formatter::SpecdocFormatter.new(*args)
+ super
end
end
end
View
2  lib/ci/reporter/version.rb
@@ -1,5 +1,5 @@
module CI
module Reporter
- VERSION = "1.4"
+ VERSION = "1.5.1"
end
end
View
5 spec/ci/reporter/rake/rake_tasks_spec.rb
@@ -59,6 +59,11 @@ def restore_env(v)
@rake["ci:setup:rspec"].invoke
ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
end
+
+ it "should set ENV['SPEC_OPTS'] to include rspec doc formatter if task is ci:setup:rspecdoc" do
+ @rake["ci:setup:rspecdoc"].invoke
+ ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecDoc/
+ end
it "should append to ENV['SPEC_OPTS'] if it already contains a value" do
ENV["SPEC_OPTS"] = "somevalue".freeze
View
74 spec/ci/reporter/rspec_spec.rb
@@ -11,30 +11,76 @@
@error.stub!(:expectation_not_met?).and_return(false)
@error.stub!(:pending_fixed?).and_return(false)
@report_mgr = mock("report manager")
- @fmt = CI::Reporter::RSpec.new(StringIO.new(""), false, false, @report_mgr)
+ @options = mock("options")
+ @args = [@options, StringIO.new("")]
+ @args.shift if Spec::VERSION::MAJOR == 1 && Spec::VERSION::MINOR < 1
+ @fmt = CI::Reporter::RSpec.new *@args
+ @fmt.report_manager = @report_mgr
+ @formatter = mock("formatter")
+ @fmt.formatter = @formatter
end
- it "should create a test suite with one success and one failure" do
+ it "should use a progress bar formatter by default" do
+ fmt = CI::Reporter::RSpec.new *@args
+ fmt.formatter.should be_instance_of(Spec::Runner::Formatter::ProgressBarFormatter)
+ end
+
+ it "should use a specdoc formatter for RSpecDoc" do
+ fmt = CI::Reporter::RSpecDoc.new *@args
+ fmt.formatter.should be_instance_of(Spec::Runner::Formatter::SpecdocFormatter)
+ end
+
+ it "should create a test suite with one success, one failure, and one pending" do
@report_mgr.should_receive(:write_report).and_return do |suite|
- suite.testcases.length.should == 2
- suite.testcases.first.should_not be_failure
- suite.testcases.first.should_not be_error
- suite.testcases.last.should be_error
+ suite.testcases.length.should == 3
+ suite.testcases[0].should_not be_failure
+ suite.testcases[0].should_not be_error
+ suite.testcases[1].should be_error
+ suite.testcases[2].name.should =~ /\(PENDING\)/
end
- @fmt.start(2)
- @fmt.add_behaviour("A context")
+ example_group = mock "example group"
+ example_group.stub!(:description).and_return "A context"
+
+ @formatter.should_receive(:start).with(3)
+ @formatter.should_receive(:add_example_group).with(example_group)
+ @formatter.should_receive(:example_started).exactly(3).times
+ @formatter.should_receive(:example_passed).once
+ @formatter.should_receive(:example_failed).once
+ @formatter.should_receive(:example_pending).once
+ @formatter.should_receive(:start_dump).once
+ @formatter.should_receive(:dump_failure).once
+ @formatter.should_receive(:dump_summary).once
+ @formatter.should_receive(:dump_pending).once
+ @formatter.should_receive(:close).once
+
+ @fmt.start(3)
+ @fmt.add_example_group(example_group)
@fmt.example_started("should pass")
@fmt.example_passed("should pass")
@fmt.example_started("should fail")
@fmt.example_failed("should fail", 1, @error)
- @fmt.dump_summary(0.1, 2, 1)
+ @fmt.example_started("should be pending")
+ @fmt.example_pending("A context", "should be pending", "Not Yet Implemented")
+ @fmt.start_dump
+ @fmt.dump_failure(1, mock("failure"))
+ @fmt.dump_summary(0.1, 3, 1, 1)
+ @fmt.dump_pending
+ @fmt.close
end
- it "should report deprecation when called with RSpec < 0.9" do
- @fmt.should_receive(:warn).exactly(2).times
- @fmt.deprecated
- @fmt.deprecated
- @fmt.deprecated
+ it "should support RSpec 1.0.8 #add_behavior" do
+ @formatter.should_receive(:start)
+ @formatter.should_receive(:add_behaviour).with("A context")
+ @formatter.should_receive(:example_started).once
+ @formatter.should_receive(:example_passed).once
+ @formatter.should_receive(:dump_summary)
+ @report_mgr.should_receive(:write_report)
+
+ @fmt.start(2)
+ @fmt.add_behaviour("A context")
+ @fmt.example_started("should pass")
+ @fmt.example_passed("should pass")
+ @fmt.dump_summary(0.1, 1, 0, 0)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.