Class: TapFormatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ TapFormatter

Returns a new instance of TapFormatter.



35
36
37
38
# File 'lib/rspec-extra-formatters/tap_formatter.rb', line 35

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



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

def dump_summary(duration, example_count, failure_count, pending_count)
  super(duration, example_count, failure_count, pending_count)
  if (@total > 0)
    output.puts("1..#{example_count}")
  end
end

#example_failed(example) ⇒ Object



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

def example_failed(example)
  super(example)
  @total += 1
  output.puts("not ok #{@total} - #{example.[:full_description]}")
end

#example_passed(example) ⇒ Object



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

def example_passed(example)
  super(example)
  @total += 1
  output.puts("ok #{@total} - #{example.[:full_description]}")
end

#example_pending(example) ⇒ Object



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

def example_pending(example)
  self.example_failed(example)
end