ci_reporter 1.2.4 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.3
2
+
3
+ - Fixed to be compatible with RSpec 0.9
4
+ - Failure location text now contains both the exception message and class name (in case the type and message attributes were truncated)
5
+
1
6
  == 1.2.4
2
7
 
3
8
  - Allow to report on RSpec specs when working with non-gem RSpec
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'hoe'
4
4
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
5
5
  "lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
6
6
 
7
- Hoe.new("ci_reporter", "1.2.4") do |p|
7
+ Hoe.new("ci_reporter", "1.3") do |p|
8
8
  p.rubyforge_name = "caldersphere"
9
9
  p.url = "http://caldersphere.rubyforge.org/ci_reporter"
10
10
  p.author = "Nick Sieger"
@@ -23,7 +23,8 @@ Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
23
23
  task :default => :spec
24
24
 
25
25
  Spec::Rake::SpecTask.new do |t|
26
- t.spec_opts = ["--diff", "unified"]
26
+ t.spec_opts ||= []
27
+ t.spec_opts << "--diff" << "unified"
27
28
  end
28
29
 
29
30
  # Automated manifest
@@ -7,7 +7,7 @@ namespace :ci do
7
7
  task :rspec do
8
8
  rm_rf ENV["CI_REPORTS"] || "spec/reports"
9
9
  ENV["RSPECOPTS"] ||= ""
10
- ENV["RSPECOPTS"] += [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
10
+ ENV["RSPECOPTS"] << [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
11
11
  "--format", "CI::Reporter::RSpec"].join(" ")
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ namespace :ci do
7
7
  task :testunit do
8
8
  rm_rf ENV["CI_REPORTS"] || "test/reports"
9
9
  ENV["TESTOPTS"] ||= ""
10
- ENV["TESTOPTS"] += " #{File.dirname(__FILE__)}/test_unit_loader.rb"
10
+ ENV["TESTOPTS"] << " #{File.dirname(__FILE__)}/test_unit_loader.rb"
11
11
  end
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@ require 'ci/reporter/core'
6
6
  begin
7
7
  gem 'rspec'
8
8
  rescue Gem::LoadError
9
- # Needed for non-gem RSpec (e.g., reporting on RSpec's own specs);
9
+ # Needed for non-gem RSpec (e.g., reporting on RSpec's own specs);
10
10
  # if spec isn't found, the next require will blow up
11
11
  end
12
12
  require 'spec'
@@ -35,7 +35,13 @@ module CI
35
35
  # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
36
36
  class RSpec < Spec::Runner::Formatter::ProgressBarFormatter
37
37
  def initialize(output, dry_run=false, colour=false, report_mgr=nil)
38
- super(output, dry_run, colour)
38
+ if respond_to? :dry_run=
39
+ super(output)
40
+ self.dry_run=dry_run
41
+ self.colour=colour
42
+ else
43
+ super(output, dry_run, colour)
44
+ end
39
45
  @report_manager = report_mgr || ReportManager.new("spec")
40
46
  @suite = nil
41
47
  end
@@ -44,31 +50,52 @@ module CI
44
50
  super
45
51
  end
46
52
 
53
+ # Pre-0.9 hook
47
54
  def add_context(name, first)
48
55
  super
49
- write_report if @suite
50
- @suite = TestSuite.new name
51
- @suite.start
56
+ new_suite(name)
57
+ end
58
+
59
+ # Post-0.9 hook
60
+ def add_behaviour(name)
61
+ super
62
+ new_suite(name)
52
63
  end
53
64
 
65
+ # Pre-0.9 hook
54
66
  def spec_started(name)
55
67
  super
56
- spec = TestCase.new name
57
- @suite.testcases << spec
58
- spec.start
68
+ case_started(name)
59
69
  end
60
70
 
71
+ # Post-0.9 hook
72
+ def example_started(name)
73
+ super
74
+ case_started(name)
75
+ end
76
+
77
+ # Pre-0.9 hook
61
78
  def spec_failed(name, counter, failure)
62
79
  super
63
- spec = @suite.testcases.last
64
- spec.finish
65
- spec.failure = RSpecFailure.new(failure)
80
+ case_failed(name, counter, failure)
81
+ end
82
+
83
+ # Post-0.9 hook
84
+ def example_failed(name, counter, failure)
85
+ super
86
+ case_failed(name, counter, failure)
66
87
  end
67
88
 
89
+ # Pre-0.9 hook
68
90
  def spec_passed(name)
69
91
  super
70
- spec = @suite.testcases.last
71
- spec.finish
92
+ case_passed(name)
93
+ end
94
+
95
+ # Post-0.9 hook
96
+ def example_passed(name)
97
+ super
98
+ case_passed(name)
72
99
  end
73
100
 
74
101
  def start_dump
@@ -79,7 +106,7 @@ module CI
79
106
  super
80
107
  end
81
108
 
82
- def dump_summary(duration, spec_count, failure_count)
109
+ def dump_summary(duration, example_count, failure_count)
83
110
  super
84
111
  write_report
85
112
  end
@@ -89,6 +116,29 @@ module CI
89
116
  @suite.finish
90
117
  @report_manager.write_report(@suite)
91
118
  end
119
+
120
+ def new_suite(name)
121
+ write_report if @suite
122
+ @suite = TestSuite.new name
123
+ @suite.start
124
+ end
125
+
126
+ def case_started(name)
127
+ spec = TestCase.new name
128
+ @suite.testcases << spec
129
+ spec.start
130
+ end
131
+
132
+ def case_failed(name, counter, failure)
133
+ spec = @suite.testcases.last
134
+ spec.finish
135
+ spec.failure = RSpecFailure.new(failure)
136
+ end
137
+
138
+ def case_passed(name)
139
+ spec = @suite.testcases.last
140
+ spec.finish
141
+ end
92
142
  end
93
143
  end
94
144
  end
@@ -141,6 +141,7 @@ module CI
141
141
  builder.testcase(attrs) do
142
142
  if failure
143
143
  builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
144
+ builder.text!(failure.message + " (#{failure.name})\n")
144
145
  builder.text!(failure.location)
145
146
  end
146
147
  end
@@ -91,7 +91,29 @@ context "TestSuite xml" do
91
91
  testcases = testsuite.elements.to_a("testcase")
92
92
  testcases.length.should == 3
93
93
  end
94
-
94
+
95
+ specify "should contain full exception type and message in location element" do
96
+ failure = mock("failure")
97
+ failure.stub!(:failure?).and_return true
98
+ failure.stub!(:error?).and_return false
99
+ failure.stub!(:name).and_return "failure"
100
+ failure.stub!(:message).and_return "There was a failure"
101
+ failure.stub!(:location).and_return @exception.backtrace.join("\n")
102
+
103
+ @suite.start
104
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
105
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
106
+ @suite.testcases.last.failure = failure
107
+ @suite.finish
108
+
109
+ xml = @suite.to_xml
110
+ doc = REXML::Document.new(xml)
111
+ elem = doc.root.elements.to_a("/testsuite/testcase[@name='failure test']/failure").first
112
+ location = elem.texts.join
113
+ location.should =~ Regexp.new(failure.message)
114
+ location.should =~ Regexp.new(failure.name)
115
+ end
116
+
95
117
  specify "should filter attributes properly for invalid characters" do
96
118
  failure = mock("failure")
97
119
  failure.stub!(:failure?).and_return true
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ci_reporter
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.4
7
- date: 2007-04-14 00:00:00 -05:00
6
+ version: "1.3"
7
+ date: 2007-05-17 00:00:00 -07:00
8
8
  summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
9
9
  require_paths:
10
10
  - lib