Class: RSpec::Retry::Formatter

Inherits:
Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/rspec/retry/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



6
7
8
9
# File 'lib/rspec/retry/formatter.rb', line 6

def initialize(output)
  super(output)
  @tries = Hash.new { |h, k| h[k] = { successes: 0, tries: 0 } }
end

Instance Method Details

#close(_) ⇒ Object



15
# File 'lib/rspec/retry/formatter.rb', line 15

def close(_); end

#dump_failures(_) ⇒ Object



17
# File 'lib/rspec/retry/formatter.rb', line 17

def dump_failures(_); end

#dump_pending(_) ⇒ Object



19
# File 'lib/rspec/retry/formatter.rb', line 19

def dump_pending(_); end

#dump_summary(notification) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rspec/retry/formatter.rb', line 21

def dump_summary(notification)
  summary = "\nRSpec Retry Summary:\n"
  @tries.each do |key, retry_data|
    next if retry_data[:successes] < 1 || retry_data[:tries] <= 1
    summary += "\t#{key.location}: #{key.full_description}: passed at attempt #{retry_data[:tries]}\n"
  end
  retried = @tries.count { |_, v| v[:tries] > 1  && v[:successes] > 0 }
  summary += "\n\t#{retried} of #{notification.example_count} tests passed with retries.\n"
  summary += "\t#{notification.failure_count} tests failed all retries.\n"
  output.puts summary
end

#example_passed(notification) ⇒ Object



33
34
35
# File 'lib/rspec/retry/formatter.rb', line 33

def example_passed(notification)
  increment_success notification.example
end

#message(_message) ⇒ Object



13
# File 'lib/rspec/retry/formatter.rb', line 13

def message(_message); end

#retry(example) ⇒ Object



37
38
39
# File 'lib/rspec/retry/formatter.rb', line 37

def retry(example)
  increment_tries example
end

#seed(_) ⇒ Object



11
# File 'lib/rspec/retry/formatter.rb', line 11

def seed(_); end