Class: CI::Reporter::RSpec2::Formatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/ci/reporter/rspec2/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Formatter

Returns a new instance of Formatter.


8
9
10
11
# File 'lib/ci/reporter/rspec2/formatter.rb', line 8

def initialize(*args)
  @report_manager = ReportManager.new("spec")
  @suite = nil
end

Instance Attribute Details

#report_managerObject

Returns the value of attribute report_manager.


7
8
9
# File 'lib/ci/reporter/rspec2/formatter.rb', line 7

def report_manager
  @report_manager
end

Instance Method Details

#dump_summary(*args) ⇒ Object


49
50
51
# File 'lib/ci/reporter/rspec2/formatter.rb', line 49

def dump_summary(*args)
  write_report
end

#example_failed(name_or_example, *rest) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ci/reporter/rspec2/formatter.rb', line 23

def example_failed(name_or_example, *rest)
  # In case we fail in before(:all)
  example_started(name_or_example) if @suite.testcases.empty?

  failure = Failure.new(name_or_example, self)

  spec = @suite.testcases.last
  spec.finish
  spec.name = description_for(name_or_example)
  spec.failures << failure
end

#example_group_started(example_group) ⇒ Object


13
14
15
# File 'lib/ci/reporter/rspec2/formatter.rb', line 13

def example_group_started(example_group)
  new_suite(description_for(example_group))
end

#example_passed(name_or_example) ⇒ Object


35
36
37
38
39
# File 'lib/ci/reporter/rspec2/formatter.rb', line 35

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

#example_pending(*args) ⇒ Object


41
42
43
44
45
46
47
# File 'lib/ci/reporter/rspec2/formatter.rb', line 41

def 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


17
18
19
20
21
# File 'lib/ci/reporter/rspec2/formatter.rb', line 17

def example_started(name_or_example)
  spec = TestCase.new
  @suite.testcases << spec
  spec.start
end