Class: CI::Reporter::RSpec
- Inherits:
-
Object
- Object
- 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.
- #dump_summary(*args) ⇒ Object
- #example_failed(name_or_example, *rest) ⇒ 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.
-
#method_missing(meth, *args, &block) ⇒ Object
Pass through other methods to RSpec formatter for compatibility.
- #respond_to?(*args) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ RSpec
Returns a new instance of RSpec.
98 99 100 101 102 |
# File 'lib/ci/reporter/rspec.rb', line 98 def initialize(*args) @formatter ||= RSpecFormatters::ProgressFormatter.new(*args) @report_manager = ReportManager.new("spec") @suite = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
Pass through other methods to RSpec formatter for compatibility
174 175 176 |
# File 'lib/ci/reporter/rspec.rb', line 174 def method_missing(meth,*args,&block) @formatter.send(meth,*args,&block) end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
97 98 99 |
# File 'lib/ci/reporter/rspec.rb', line 97 def formatter @formatter end |
#report_manager ⇒ Object
Returns the value of attribute report_manager.
96 97 98 |
# File 'lib/ci/reporter/rspec.rb', line 96 def report_manager @report_manager end |
Instance Method Details
#add_behaviour(name) ⇒ Object
rspec 0.9
105 106 107 108 |
# File 'lib/ci/reporter/rspec.rb', line 105 def add_behaviour(name) @formatter.add_behaviour(name) new_suite(name) end |
#add_example_group(example_group) ⇒ Object
Compatibility with rspec < 1.2.4
111 112 113 114 |
# File 'lib/ci/reporter/rspec.rb', line 111 def add_example_group(example_group) @formatter.add_example_group(example_group) new_suite(description_for(example_group)) end |
#dump_summary(*args) ⇒ Object
163 164 165 166 167 |
# File 'lib/ci/reporter/rspec.rb', line 163 def dump_summary(*args) @formatter.dump_summary(*args) write_report @formatter.dump_failures end |
#example_failed(name_or_example, *rest) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ci/reporter/rspec.rb', line 129 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_started(example_group) ⇒ Object
rspec >= 1.2.4
117 118 119 120 |
# File 'lib/ci/reporter/rspec.rb', line 117 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
147 148 149 150 151 152 |
# File 'lib/ci/reporter/rspec.rb', line 147 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
154 155 156 157 158 159 160 161 |
# File 'lib/ci/reporter/rspec.rb', line 154 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
122 123 124 125 126 127 |
# File 'lib/ci/reporter/rspec.rb', line 122 def example_started(name_or_example) @formatter.example_started(name_or_example) spec = TestCase.new @suite.testcases << spec spec.start end |
#respond_to?(*args) ⇒ Boolean
169 170 171 |
# File 'lib/ci/reporter/rspec.rb', line 169 def respond_to?(*args) @formatter.respond_to?(*args) end |