| Class | CI::Reporter::RSpec |
| In: |
lib/ci/reporter/rspec.rb
|
| Parent: | RSpecFormatters::BaseFormatter |
Custom RSpec formatter used to hook into the spec runs and capture results.
| formatter | [RW] | |
| report_manager | [RW] |
# File lib/ci/reporter/rspec.rb, line 66
66: def initialize(*args)
67: super
68: @formatter ||= RSpecFormatters::ProgressFormatter.new(*args)
69: @report_manager = ReportManager.new("spec")
70: @suite = nil
71: end
rspec 0.9
# File lib/ci/reporter/rspec.rb, line 78
78: def add_behaviour(name)
79: @formatter.add_behaviour(name)
80: new_suite(name)
81: end
Compatibility with rspec < 1.2.4
# File lib/ci/reporter/rspec.rb, line 84
84: def add_example_group(example_group)
85: @formatter.add_example_group(example_group)
86: new_suite(description_for(example_group))
87: end
# File lib/ci/reporter/rspec.rb, line 140
140: def dump_failure(*args)
141: @formatter.dump_failure(*args)
142: end
# File lib/ci/reporter/rspec.rb, line 149
149: def dump_pending
150: @formatter.dump_pending
151: end
# File lib/ci/reporter/rspec.rb, line 144
144: def dump_summary(*args)
145: @formatter.dump_summary(*args)
146: write_report
147: end
# File lib/ci/reporter/rspec.rb, line 102
102: def example_failed(name_or_example, *rest)
103: @formatter.example_failed(name_or_example, *rest)
104:
105: # In case we fail in before(:all)
106: example_started(name_or_example) if @suite.testcases.empty?
107:
108: if name_or_example.respond_to?(:execution_result) # RSpec 2
109: failure = RSpec2Failure.new(name_or_example)
110: else
111: failure = RSpecFailure.new(rest[1]) # example_failed(name, counter, failure) in RSpec 1
112: end
113:
114: spec = @suite.testcases.last
115: spec.finish
116: spec.name = description_for(name_or_example)
117: spec.failures << failure
118: end
rspec >= 1.2.4
# File lib/ci/reporter/rspec.rb, line 90
90: def example_group_started(example_group)
91: @formatter.example_group_started(example_group)
92: new_suite(description_for(example_group))
93: end
# File lib/ci/reporter/rspec.rb, line 120
120: def example_passed(name_or_example)
121: @formatter.example_passed(name_or_example)
122: spec = @suite.testcases.last
123: spec.finish
124: spec.name = description_for(name_or_example)
125: end
# File lib/ci/reporter/rspec.rb, line 127
127: def example_pending(*args)
128: @formatter.example_pending(*args)
129: name = description_for(args[0])
130: spec = @suite.testcases.last
131: spec.finish
132: spec.name = "#{name} (PENDING)"
133: spec.skipped = true
134: end
# File lib/ci/reporter/rspec.rb, line 95
95: def example_started(name_or_example)
96: @formatter.example_started(name_or_example)
97: spec = TestCase.new
98: @suite.testcases << spec
99: spec.start
100: end
# File lib/ci/reporter/rspec.rb, line 73
73: def start(spec_count)
74: @formatter.start(spec_count)
75: end