ci_reporter 1.4 → 1.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 +8 -0
- data/Rakefile +9 -4
- data/lib/ci/reporter/rake/rspec.rb +10 -3
- data/lib/ci/reporter/rspec.rb +58 -85
- data/lib/ci/reporter/version.rb +1 -1
- data/spec/ci/reporter/rake/rake_tasks_spec.rb +5 -0
- data/spec/ci/reporter/rspec_spec.rb +60 -14
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.5
|
2
|
+
|
3
|
+
- Support for RSpec 1.1.1 example groups (which broke ci_reporter 1.4)
|
4
|
+
- Change internal model to delegation instead of inheritance, allowing ci_reporter to wrap different output formatters
|
5
|
+
- Add 'ci:setup:rspecdoc' task to output specdoc format instead of progress
|
6
|
+
- Add support for pending examples; they will be listed in the report XML as successful, but the name will have a '(PENDING)' tag appended
|
7
|
+
- Support for RSpec < 0.9 removed as promised; use 1.4 if you still need to use an older version of RSpec
|
8
|
+
|
1
9
|
== 1.4
|
2
10
|
|
3
11
|
- Test::Unit tests that fail in multiple places (setup, test method, and teardown) are now tracked (marcog)
|
data/Rakefile
CHANGED
@@ -30,11 +30,15 @@ end
|
|
30
30
|
# !@#$ no easy way to empty the default list of prerequisites
|
31
31
|
Rake::Task['default'].send :instance_variable_set, "@prerequisites", FileList[]
|
32
32
|
|
33
|
-
|
33
|
+
# No RCov on JRuby at the moment
|
34
|
+
if RUBY_PLATFORM =~ /java/
|
35
|
+
task :default => :spec
|
36
|
+
else
|
37
|
+
task :default => :rcov
|
38
|
+
end
|
34
39
|
|
35
40
|
Spec::Rake::SpecTask.new do |t|
|
36
|
-
t.spec_opts
|
37
|
-
t.spec_opts << "--diff" << "unified"
|
41
|
+
t.spec_opts = ["--diff", "unified"]
|
38
42
|
end
|
39
43
|
|
40
44
|
Spec::Rake::SpecTask.new("spec:rcov") do |t|
|
@@ -44,7 +48,7 @@ end
|
|
44
48
|
RCov::VerifyTask.new(:rcov) do |t|
|
45
49
|
# Can't get threshold up to 100 until the RSpec < 1.0 compatibility
|
46
50
|
# code is dropped
|
47
|
-
t.threshold =
|
51
|
+
t.threshold = 99
|
48
52
|
t.require_exact_threshold = false
|
49
53
|
end
|
50
54
|
task "spec:rcov" do
|
@@ -53,6 +57,7 @@ end
|
|
53
57
|
task :rcov => "spec:rcov"
|
54
58
|
|
55
59
|
task :generate_output do
|
60
|
+
rm_f "acceptance/reports/*.xml"
|
56
61
|
ENV['CI_REPORTS'] = "acceptance/reports"
|
57
62
|
begin
|
58
63
|
`ruby -Ilib acceptance/test_unit_example_test.rb` rescue nil
|
@@ -4,13 +4,20 @@
|
|
4
4
|
|
5
5
|
namespace :ci do
|
6
6
|
namespace :setup do
|
7
|
-
task :
|
7
|
+
task :spec_report_cleanup do
|
8
8
|
rm_rf ENV["CI_REPORTS"] || "spec/reports"
|
9
|
+
end
|
10
|
+
|
11
|
+
task :rspec => :spec_report_cleanup do
|
9
12
|
spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
|
10
13
|
"--format", "CI::Reporter::RSpec"].join(" ")
|
11
14
|
ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
|
12
|
-
|
13
|
-
|
15
|
+
end
|
16
|
+
|
17
|
+
task :rspecdoc => :spec_report_cleanup do
|
18
|
+
spec_opts = ["--require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
|
19
|
+
"--format", "CI::Reporter::RSpecDoc"].join(" ")
|
20
|
+
ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
|
14
21
|
end
|
15
22
|
end
|
16
23
|
end
|
data/lib/ci/reporter/rspec.rb
CHANGED
@@ -3,13 +3,19 @@
|
|
3
3
|
# software license details.
|
4
4
|
|
5
5
|
require 'ci/reporter/core'
|
6
|
+
tried_gem = false
|
6
7
|
begin
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
11
18
|
end
|
12
|
-
require 'spec'
|
13
19
|
|
14
20
|
module CI
|
15
21
|
module Reporter
|
@@ -33,101 +39,78 @@ module CI
|
|
33
39
|
end
|
34
40
|
|
35
41
|
# Custom +RSpec+ formatter used to hook into the spec runs and capture results.
|
36
|
-
class RSpec < Spec::Runner::Formatter::
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
super(output, dry_run, colour)
|
44
|
-
end
|
45
|
-
@report_manager = report_mgr || ReportManager.new("spec")
|
42
|
+
class RSpec < Spec::Runner::Formatter::BaseFormatter
|
43
|
+
attr_accessor :report_manager
|
44
|
+
attr_accessor :formatter
|
45
|
+
def initialize(*args)
|
46
|
+
super
|
47
|
+
@formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
|
48
|
+
@report_manager = ReportManager.new("spec")
|
46
49
|
@suite = nil
|
47
50
|
end
|
48
51
|
|
49
|
-
def deprecated
|
50
|
-
unless @warned
|
51
|
-
require 'ci/reporter/version'
|
52
|
-
warn "warning: use of RSpec < 0.9 with CI::Reporter #{CI::Reporter::VERSION} is deprecated;"
|
53
|
-
warn "a future version will not be compatible."
|
54
|
-
end
|
55
|
-
@warned = true
|
56
|
-
end
|
57
|
-
|
58
52
|
def start(spec_count)
|
59
|
-
|
53
|
+
@formatter.start(spec_count)
|
60
54
|
end
|
61
55
|
|
62
|
-
# Pre-0.9 hook
|
63
|
-
def add_context(name, first)
|
64
|
-
super
|
65
|
-
deprecated
|
66
|
-
new_suite(name)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Post-0.9 hook
|
70
56
|
def add_behaviour(name)
|
71
|
-
|
57
|
+
@formatter.add_behaviour(name)
|
72
58
|
new_suite(name)
|
73
59
|
end
|
74
60
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
deprecated
|
79
|
-
case_started(name)
|
61
|
+
def add_example_group(example_group)
|
62
|
+
@formatter.add_example_group(example_group)
|
63
|
+
new_suite(example_group.description)
|
80
64
|
end
|
81
65
|
|
82
|
-
# Post-0.9 hook
|
83
66
|
def example_started(name)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# Pre-0.9 hook
|
89
|
-
def spec_failed(name, counter, failure)
|
90
|
-
super
|
91
|
-
deprecated
|
92
|
-
case_failed(name, counter, failure)
|
67
|
+
@formatter.example_started(name)
|
68
|
+
spec = TestCase.new name
|
69
|
+
@suite.testcases << spec
|
70
|
+
spec.start
|
93
71
|
end
|
94
72
|
|
95
|
-
# Post-0.9 hook
|
96
73
|
def example_failed(name, counter, failure)
|
97
|
-
|
98
|
-
|
74
|
+
@formatter.example_failed(name, counter, failure)
|
75
|
+
spec = @suite.testcases.last
|
76
|
+
spec.finish
|
77
|
+
spec.failures << RSpecFailure.new(failure)
|
99
78
|
end
|
100
79
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
case_passed(name)
|
80
|
+
def example_passed(name)
|
81
|
+
@formatter.example_passed(name)
|
82
|
+
spec = @suite.testcases.last
|
83
|
+
spec.finish
|
106
84
|
end
|
107
85
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
86
|
+
def example_pending(*args)
|
87
|
+
@formatter.example_pending(*args)
|
88
|
+
spec = @suite.testcases.last
|
89
|
+
spec.finish
|
90
|
+
spec.name = "#{spec.name} (PENDING)"
|
112
91
|
end
|
113
92
|
|
114
93
|
def start_dump
|
115
|
-
|
94
|
+
@formatter.start_dump
|
116
95
|
end
|
117
96
|
|
118
|
-
def dump_failure(
|
119
|
-
|
97
|
+
def dump_failure(*args)
|
98
|
+
@formatter.dump_failure(*args)
|
120
99
|
end
|
121
100
|
|
122
|
-
def dump_summary(
|
123
|
-
|
124
|
-
super
|
125
|
-
rescue ArgumentError
|
126
|
-
super(duration, example_count, failure_count)
|
127
|
-
end
|
101
|
+
def dump_summary(*args)
|
102
|
+
@formatter.dump_summary(*args)
|
128
103
|
write_report
|
129
104
|
end
|
130
105
|
|
106
|
+
def dump_pending
|
107
|
+
@formatter.dump_pending
|
108
|
+
end
|
109
|
+
|
110
|
+
def close
|
111
|
+
@formatter.close
|
112
|
+
end
|
113
|
+
|
131
114
|
private
|
132
115
|
def write_report
|
133
116
|
@suite.finish
|
@@ -139,22 +122,12 @@ module CI
|
|
139
122
|
@suite = TestSuite.new name
|
140
123
|
@suite.start
|
141
124
|
end
|
125
|
+
end
|
142
126
|
|
143
|
-
|
144
|
-
|
145
|
-
@
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
def case_failed(name, counter, failure)
|
150
|
-
spec = @suite.testcases.last
|
151
|
-
spec.finish
|
152
|
-
spec.failures << RSpecFailure.new(failure)
|
153
|
-
end
|
154
|
-
|
155
|
-
def case_passed(name)
|
156
|
-
spec = @suite.testcases.last
|
157
|
-
spec.finish
|
127
|
+
class RSpecDoc < RSpec
|
128
|
+
def initialize(*args)
|
129
|
+
@formatter = Spec::Runner::Formatter::SpecdocFormatter.new(*args)
|
130
|
+
super
|
158
131
|
end
|
159
132
|
end
|
160
133
|
end
|
data/lib/ci/reporter/version.rb
CHANGED
@@ -59,6 +59,11 @@ describe "ci_reporter ci:setup:rspec task" do
|
|
59
59
|
@rake["ci:setup:rspec"].invoke
|
60
60
|
ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
|
61
61
|
end
|
62
|
+
|
63
|
+
it "should set ENV['SPEC_OPTS'] to include rspec doc formatter if task is ci:setup:rspecdoc" do
|
64
|
+
@rake["ci:setup:rspecdoc"].invoke
|
65
|
+
ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecDoc/
|
66
|
+
end
|
62
67
|
|
63
68
|
it "should append to ENV['SPEC_OPTS'] if it already contains a value" do
|
64
69
|
ENV["SPEC_OPTS"] = "somevalue".freeze
|
@@ -11,30 +11,76 @@ describe "The RSpec reporter" do
|
|
11
11
|
@error.stub!(:expectation_not_met?).and_return(false)
|
12
12
|
@error.stub!(:pending_fixed?).and_return(false)
|
13
13
|
@report_mgr = mock("report manager")
|
14
|
-
@
|
14
|
+
@options = mock("options")
|
15
|
+
@args = [@options, StringIO.new("")]
|
16
|
+
@args.shift if Spec::VERSION::MAJOR == 1 && Spec::VERSION::MINOR < 1
|
17
|
+
@fmt = CI::Reporter::RSpec.new *@args
|
18
|
+
@fmt.report_manager = @report_mgr
|
19
|
+
@formatter = mock("formatter")
|
20
|
+
@fmt.formatter = @formatter
|
15
21
|
end
|
16
22
|
|
17
|
-
it "should
|
23
|
+
it "should use a progress bar formatter by default" do
|
24
|
+
fmt = CI::Reporter::RSpec.new *@args
|
25
|
+
fmt.formatter.should be_instance_of(Spec::Runner::Formatter::ProgressBarFormatter)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should use a specdoc formatter for RSpecDoc" do
|
29
|
+
fmt = CI::Reporter::RSpecDoc.new *@args
|
30
|
+
fmt.formatter.should be_instance_of(Spec::Runner::Formatter::SpecdocFormatter)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create a test suite with one success, one failure, and one pending" do
|
18
34
|
@report_mgr.should_receive(:write_report).and_return do |suite|
|
19
|
-
suite.testcases.length.should ==
|
20
|
-
suite.testcases.
|
21
|
-
suite.testcases.
|
22
|
-
suite.testcases.
|
35
|
+
suite.testcases.length.should == 3
|
36
|
+
suite.testcases[0].should_not be_failure
|
37
|
+
suite.testcases[0].should_not be_error
|
38
|
+
suite.testcases[1].should be_error
|
39
|
+
suite.testcases[2].name.should =~ /\(PENDING\)/
|
23
40
|
end
|
24
41
|
|
25
|
-
|
26
|
-
|
42
|
+
example_group = mock "example group"
|
43
|
+
example_group.stub!(:description).and_return "A context"
|
44
|
+
|
45
|
+
@formatter.should_receive(:start).with(3)
|
46
|
+
@formatter.should_receive(:add_example_group).with(example_group)
|
47
|
+
@formatter.should_receive(:example_started).exactly(3).times
|
48
|
+
@formatter.should_receive(:example_passed).once
|
49
|
+
@formatter.should_receive(:example_failed).once
|
50
|
+
@formatter.should_receive(:example_pending).once
|
51
|
+
@formatter.should_receive(:start_dump).once
|
52
|
+
@formatter.should_receive(:dump_failure).once
|
53
|
+
@formatter.should_receive(:dump_summary).once
|
54
|
+
@formatter.should_receive(:dump_pending).once
|
55
|
+
@formatter.should_receive(:close).once
|
56
|
+
|
57
|
+
@fmt.start(3)
|
58
|
+
@fmt.add_example_group(example_group)
|
27
59
|
@fmt.example_started("should pass")
|
28
60
|
@fmt.example_passed("should pass")
|
29
61
|
@fmt.example_started("should fail")
|
30
62
|
@fmt.example_failed("should fail", 1, @error)
|
31
|
-
@fmt.
|
63
|
+
@fmt.example_started("should be pending")
|
64
|
+
@fmt.example_pending("A context", "should be pending", "Not Yet Implemented")
|
65
|
+
@fmt.start_dump
|
66
|
+
@fmt.dump_failure(1, mock("failure"))
|
67
|
+
@fmt.dump_summary(0.1, 3, 1, 1)
|
68
|
+
@fmt.dump_pending
|
69
|
+
@fmt.close
|
32
70
|
end
|
33
71
|
|
34
|
-
it "should
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
72
|
+
it "should support RSpec 1.0.8 #add_behavior" do
|
73
|
+
@formatter.should_receive(:start)
|
74
|
+
@formatter.should_receive(:add_behaviour).with("A context")
|
75
|
+
@formatter.should_receive(:example_started).once
|
76
|
+
@formatter.should_receive(:example_passed).once
|
77
|
+
@formatter.should_receive(:dump_summary)
|
78
|
+
@report_mgr.should_receive(:write_report)
|
79
|
+
|
80
|
+
@fmt.start(2)
|
81
|
+
@fmt.add_behaviour("A context")
|
82
|
+
@fmt.example_started("should pass")
|
83
|
+
@fmt.example_passed("should pass")
|
84
|
+
@fmt.dump_summary(0.1, 1, 0, 0)
|
39
85
|
end
|
40
86
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ci_reporter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date:
|
6
|
+
version: "1.5"
|
7
|
+
date: 2008-01-12 00:00:00 -06: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
|