Class: CI::Reporter::RSpec

Inherits:
Spec::Runner::Formatter::BaseFormatter
  • Object
show all
Defined in:
lib/ci/reporter/rspec.rb

Overview

Custom RSpec formatter used to hook into the spec runs and capture results.

Direct Known Subclasses

RSpecDoc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RSpec

Returns a new instance of RSpec.



45
46
47
48
49
50
# File 'lib/ci/reporter/rspec.rb', line 45

def initialize(*args)
  super
  @formatter ||= Spec::Runner::Formatter::ProgressBarFormatter.new(*args)
  @report_manager = ReportManager.new("spec")
  @suite = nil
end

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



44
45
46
# File 'lib/ci/reporter/rspec.rb', line 44

def formatter
  @formatter
end

#report_managerObject

Returns the value of attribute report_manager.



43
44
45
# File 'lib/ci/reporter/rspec.rb', line 43

def report_manager
  @report_manager
end

Instance Method Details

#add_behaviour(name) ⇒ Object

rspec 0.9



57
58
59
60
# File 'lib/ci/reporter/rspec.rb', line 57

def add_behaviour(name)
  @formatter.add_behaviour(name)
  new_suite(name)
end

#add_example_group(example_group) ⇒ Object

Compatibility with rspec < 1.2.4



63
64
65
66
# File 'lib/ci/reporter/rspec.rb', line 63

def add_example_group(example_group)
  @formatter.add_example_group(example_group)
  new_suite(example_group.description)
end

#closeObject



119
120
121
# File 'lib/ci/reporter/rspec.rb', line 119

def close
  @formatter.close
end

#dump_failure(*args) ⇒ Object



106
107
108
# File 'lib/ci/reporter/rspec.rb', line 106

def dump_failure(*args)
  @formatter.dump_failure(*args)
end

#dump_pendingObject



115
116
117
# File 'lib/ci/reporter/rspec.rb', line 115

def dump_pending
  @formatter.dump_pending
end

#dump_summary(*args) ⇒ Object



110
111
112
113
# File 'lib/ci/reporter/rspec.rb', line 110

def dump_summary(*args)
  @formatter.dump_summary(*args)
  write_report
end

#example_failed(name, counter, failure) ⇒ Object



82
83
84
85
86
87
# File 'lib/ci/reporter/rspec.rb', line 82

def example_failed(name, counter, failure)
  @formatter.example_failed(name, counter, failure)
  spec = @suite.testcases.last
  spec.finish
  spec.failures << RSpecFailure.new(failure)
end

#example_group_started(example_group) ⇒ Object

rspec >= 1.2.4



69
70
71
72
# File 'lib/ci/reporter/rspec.rb', line 69

def example_group_started(example_group)
  @formatter.example_group_started(example_group)
  new_suite(example_group.description)
end

#example_passed(name) ⇒ Object



89
90
91
92
93
# File 'lib/ci/reporter/rspec.rb', line 89

def example_passed(name)
  @formatter.example_passed(name)
  spec = @suite.testcases.last
  spec.finish
end

#example_pending(*args) ⇒ Object



95
96
97
98
99
100
# File 'lib/ci/reporter/rspec.rb', line 95

def example_pending(*args)
  @formatter.example_pending(*args)
  spec = @suite.testcases.last
  spec.finish
  spec.name = "#{spec.name} (PENDING)"
end

#example_started(name) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/ci/reporter/rspec.rb', line 74

def example_started(name)
  @formatter.example_started(name)
  name = name.description if name.respond_to?(:description)
  spec = TestCase.new name
  @suite.testcases << spec
  spec.start
end

#start(spec_count) ⇒ Object



52
53
54
# File 'lib/ci/reporter/rspec.rb', line 52

def start(spec_count)
  @formatter.start(spec_count)
end

#start_dumpObject



102
103
104
# File 'lib/ci/reporter/rspec.rb', line 102

def start_dump
  @formatter.start_dump
end