Permalink
Browse files

Preparing for 1.3 release

- Include full message in failure/error stack trace
- RSpec 0.9 compatibility


git-svn-id: http://svn.caldersphere.net/svn/main/rubyforge/ci_reporter/trunk@93 b03c2d0b-2f10-0410-a2f9-fc8001506dfa
  • Loading branch information...
1 parent 6dfadcd commit 68aca7cbe87d516fa218e62bb084bd1757e7f2a6 @nicksieger nicksieger committed May 17, 2007
View
5 History.txt
@@ -1,3 +1,8 @@
+== 1.3
+
+- Fixed to be compatible with RSpec 0.9
+- Failure location text now contains both the exception message and class name (in case the type and message attributes were truncated)
+
== 1.2.4
- Allow to report on RSpec specs when working with non-gem RSpec
View
5 Rakefile
@@ -4,7 +4,7 @@ require 'hoe'
MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
"lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
-Hoe.new("ci_reporter", "1.2.5") do |p|
+Hoe.new("ci_reporter", "1.3") do |p|
p.rubyforge_name = "caldersphere"
p.url = "http://caldersphere.rubyforge.org/ci_reporter"
p.author = "Nick Sieger"
@@ -23,7 +23,8 @@ Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
task :default => :spec
Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ["--diff", "unified"]
+ t.spec_opts ||= []
+ t.spec_opts << "--diff" << "unified"
end
# Automated manifest
View
2 lib/ci/reporter/rake/rspec.rb
@@ -7,7 +7,7 @@
task :rspec do
rm_rf ENV["CI_REPORTS"] || "spec/reports"
ENV["RSPECOPTS"] ||= ""
- ENV["RSPECOPTS"] += [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
+ ENV["RSPECOPTS"] << [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
"--format", "CI::Reporter::RSpec"].join(" ")
end
end
View
2 lib/ci/reporter/rake/test_unit.rb
@@ -7,7 +7,7 @@
task :testunit do
rm_rf ENV["CI_REPORTS"] || "test/reports"
ENV["TESTOPTS"] ||= ""
- ENV["TESTOPTS"] += " #{File.dirname(__FILE__)}/test_unit_loader.rb"
+ ENV["TESTOPTS"] << " #{File.dirname(__FILE__)}/test_unit_loader.rb"
end
end
end
View
78 lib/ci/reporter/rspec.rb
@@ -6,7 +6,7 @@
begin
gem 'rspec'
rescue Gem::LoadError
- # Needed for non-gem RSpec (e.g., reporting on RSpec's own specs);
+ # Needed for non-gem RSpec (e.g., reporting on RSpec's own specs);
# if spec isn't found, the next require will blow up
end
require 'spec'
@@ -35,7 +35,13 @@ def location() @failure.exception.backtrace.join("\n") 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)
- super(output, dry_run, colour)
+ 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")
@suite = nil
end
@@ -44,31 +50,52 @@ def start(spec_count)
super
end
+ # Pre-0.9 hook
def add_context(name, first)
super
- write_report if @suite
- @suite = TestSuite.new name
- @suite.start
+ new_suite(name)
+ end
+
+ # Post-0.9 hook
+ def add_behaviour(name)
+ super
+ new_suite(name)
end
+ # Pre-0.9 hook
def spec_started(name)
super
- spec = TestCase.new name
- @suite.testcases << spec
- spec.start
+ case_started(name)
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
- spec = @suite.testcases.last
- spec.finish
- spec.failure = RSpecFailure.new(failure)
+ case_failed(name, counter, failure)
+ end
+
+ # Post-0.9 hook
+ def example_failed(name, counter, failure)
+ super
+ case_failed(name, counter, failure)
end
+ # Pre-0.9 hook
def spec_passed(name)
super
- spec = @suite.testcases.last
- spec.finish
+ case_passed(name)
+ end
+
+ # Post-0.9 hook
+ def example_passed(name)
+ super
+ case_passed(name)
end
def start_dump
@@ -79,7 +106,7 @@ def dump_failure(counter, failure)
super
end
- def dump_summary(duration, spec_count, failure_count)
+ def dump_summary(duration, example_count, failure_count)
super
write_report
end
@@ -89,6 +116,29 @@ def write_report
@suite.finish
@report_manager.write_report(@suite)
end
+
+ def new_suite(name)
+ write_report if @suite
+ @suite = TestSuite.new name
+ @suite.start
+ 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.failure = RSpecFailure.new(failure)
+ end
+
+ def case_passed(name)
+ spec = @suite.testcases.last
+ spec.finish
+ end
end
end
end
View
1 lib/ci/reporter/test_suite.rb
@@ -141,6 +141,7 @@ def to_xml(builder)
builder.testcase(attrs) do
if failure
builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
+ builder.text!(failure.message + " (#{failure.name})\n")
builder.text!(failure.location)
end
end
View
24 spec/ci/reporter/test_suite_spec.rb
@@ -91,7 +91,29 @@
testcases = testsuite.elements.to_a("testcase")
testcases.length.should == 3
end
-
+
+ specify "should contain full exception type and message in location element" do
+ failure = mock("failure")
+ failure.stub!(:failure?).and_return true
+ failure.stub!(:error?).and_return false
+ failure.stub!(:name).and_return "failure"
+ failure.stub!(:message).and_return "There was a failure"
+ failure.stub!(:location).and_return @exception.backtrace.join("\n")
+
+ @suite.start
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
+ @suite.testcases.last.failure = failure
+ @suite.finish
+
+ xml = @suite.to_xml
+ doc = REXML::Document.new(xml)
+ elem = doc.root.elements.to_a("/testsuite/testcase[@name='failure test']/failure").first
+ location = elem.texts.join
+ location.should =~ Regexp.new(failure.message)
+ location.should =~ Regexp.new(failure.name)
+ end
+
specify "should filter attributes properly for invalid characters" do
failure = mock("failure")
failure.stub!(:failure?).and_return true

0 comments on commit 68aca7c

Please sign in to comment.