Class: CI::Reporter::RSpec
- Inherits:
-
RSpecFormatters::BaseFormatter
- Object
- RSpecFormatters::BaseFormatter
- CI::Reporter::RSpec
- Defined in:
- lib/ci/reporter/rspec.rb
Overview
Custom RSpec
formatter used to hook into the spec runs and capture results.
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#report_manager ⇒ Object
Returns the value of attribute report_manager.
Instance Method Summary collapse
-
#add_behaviour(name) ⇒ Object
rspec 0.9.
-
#add_example_group(example_group) ⇒ Object
Compatibility with rspec < 1.2.4.
- #close ⇒ Object
- #dump_failure(*args) ⇒ Object
- #dump_failures(*args) ⇒ Object
- #dump_pending ⇒ Object
- #dump_summary(*args) ⇒ Object
- #example_failed(name_or_example, *rest) ⇒ Object
- #example_group_finished(example_group) ⇒ Object
-
#example_group_started(example_group) ⇒ Object
rspec >= 1.2.4.
- #example_passed(name_or_example) ⇒ Object
- #example_pending(*args) ⇒ Object
- #example_started(name_or_example) ⇒ Object
-
#initialize(*args) ⇒ RSpec
constructor
A new instance of RSpec.
- #start(spec_count) ⇒ Object
- #start_dump ⇒ Object
Constructor Details
#initialize(*args) ⇒ RSpec
Returns a new instance of RSpec.
88 89 90 91 92 93 |
# File 'lib/ci/reporter/rspec.rb', line 88 def initialize(*args) super @formatter ||= RSpecFormatters::ProgressFormatter.new(*args) @report_manager = ReportManager.new("spec") @suite = nil end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
87 88 89 |
# File 'lib/ci/reporter/rspec.rb', line 87 def formatter @formatter end |
#report_manager ⇒ Object
Returns the value of attribute report_manager.
86 87 88 |
# File 'lib/ci/reporter/rspec.rb', line 86 def report_manager @report_manager end |
Instance Method Details
#add_behaviour(name) ⇒ Object
rspec 0.9
100 101 102 103 |
# File 'lib/ci/reporter/rspec.rb', line 100 def add_behaviour(name) @formatter.add_behaviour(name) new_suite(name) end |
#add_example_group(example_group) ⇒ Object
Compatibility with rspec < 1.2.4
106 107 108 109 |
# File 'lib/ci/reporter/rspec.rb', line 106 def add_example_group(example_group) @formatter.add_example_group(example_group) new_suite(description_for(example_group)) end |
#close ⇒ Object
184 185 186 |
# File 'lib/ci/reporter/rspec.rb', line 184 def close @formatter.close end |
#dump_failure(*args) ⇒ Object
170 171 172 |
# File 'lib/ci/reporter/rspec.rb', line 170 def dump_failure(*args) @formatter.dump_failure(*args) end |
#dump_failures(*args) ⇒ Object
166 167 168 |
# File 'lib/ci/reporter/rspec.rb', line 166 def dump_failures(*args) @formatter.dump_failures(*args) end |
#dump_pending ⇒ Object
180 181 182 |
# File 'lib/ci/reporter/rspec.rb', line 180 def dump_pending @formatter.dump_pending end |
#dump_summary(*args) ⇒ Object
174 175 176 177 178 |
# File 'lib/ci/reporter/rspec.rb', line 174 def dump_summary(*args) @formatter.dump_summary(*args) write_report @formatter.dump_failures end |
#example_failed(name_or_example, *rest) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ci/reporter/rspec.rb', line 128 def example_failed(name_or_example, *rest) @formatter.example_failed(name_or_example, *rest) # In case we fail in before(:all) example_started(name_or_example) if @suite.testcases.empty? if name_or_example.respond_to?(:execution_result) # RSpec 2 failure = RSpec2Failure.new(name_or_example, @formatter) else failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1 end spec = @suite.testcases.last spec.finish spec.name = description_for(name_or_example) spec.failures << failure end |
#example_group_finished(example_group) ⇒ Object
117 118 119 |
# File 'lib/ci/reporter/rspec.rb', line 117 def example_group_finished(example_group) @formatter.example_group_finished(example_group) end |
#example_group_started(example_group) ⇒ Object
rspec >= 1.2.4
112 113 114 115 |
# File 'lib/ci/reporter/rspec.rb', line 112 def example_group_started(example_group) @formatter.example_group_started(example_group) new_suite(description_for(example_group)) end |
#example_passed(name_or_example) ⇒ Object
146 147 148 149 150 151 |
# File 'lib/ci/reporter/rspec.rb', line 146 def example_passed(name_or_example) @formatter.example_passed(name_or_example) spec = @suite.testcases.last spec.finish spec.name = description_for(name_or_example) end |
#example_pending(*args) ⇒ Object
153 154 155 156 157 158 159 160 |
# File 'lib/ci/reporter/rspec.rb', line 153 def example_pending(*args) @formatter.example_pending(*args) name = description_for(args[0]) spec = @suite.testcases.last spec.finish spec.name = "#{name} (PENDING)" spec.skipped = true end |
#example_started(name_or_example) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/ci/reporter/rspec.rb', line 121 def example_started(name_or_example) @formatter.example_started(name_or_example) spec = TestCase.new @suite.testcases << spec spec.start end |
#start(spec_count) ⇒ Object
95 96 97 |
# File 'lib/ci/reporter/rspec.rb', line 95 def start(spec_count) @formatter.start(spec_count) end |
#start_dump ⇒ Object
162 163 164 |
# File 'lib/ci/reporter/rspec.rb', line 162 def start_dump @formatter.start_dump end |