Class: TapFormatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/rspec-extra-formatters/tap_formatter.rb

Constant Summary collapse

OK =
'ok'
NOT_OK =
'not ok'
TODO =
'# TODO '
SKIP =
'# SKIP '

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ TapFormatter

Returns a new instance of TapFormatter.



40
41
42
43
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 40

def initialize(output)
  super(output)      
  @total = 0
end

Instance Attribute Details

#totalObject (readonly)

Returns the value of attribute total.



33
34
35
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 33

def total
  @total
end

Instance Method Details

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



72
73
74
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 72

def dump_summary(duration, example_count, failure_count, pending_count)
  super(duration, example_count, failure_count, pending_count)
end

#example_failed(example) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 62

def example_failed(example)
  super(example)
  tap_example_output(NOT_OK, example)
  output.puts("    ---")
  my_exception = example.exception.to_s
  my_exception.gsub! /"/, ''
  output.puts("     #{my_exception} ")
  output.puts("     ...")
end

#example_passed(example) ⇒ Object



52
53
54
55
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 52

def example_passed(example)
  super(example)
  tap_example_output(OK, example)
end

#example_pending(example) ⇒ Object



57
58
59
60
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 57

def example_pending(example)
  super(example)
  tap_example_output(NOT_OK, example, SKIP)
end

#start(example_count) ⇒ Object



45
46
47
48
49
50
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 45

def start(example_count)
    super(example_count)
    output.puts("TAP version 13")
    output.puts("1.." + example_count.to_s)

end