Class: RSpec::Rerun::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-rerun/formatter.rb

Constant Summary collapse

FILENAME =
'rspec.failures'

Instance Method Summary collapse

Constructor Details

#initialize(_) ⇒ Formatter

Returns a new instance of Formatter.



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

def initialize(_); end

Instance Method Details

#clean!Object



22
23
24
# File 'lib/rspec-rerun/formatter.rb', line 22

def clean!
  File.delete FILENAME if File.exist? FILENAME
end

#dump_failures(notification) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rspec-rerun/formatter.rb', line 13

def dump_failures(notification)
  if notification.failed_examples.empty?
    clean!
  else
    rerun_commands = notification.failed_examples.map { |e| retry_command(e) }
    File.write(FILENAME, rerun_commands.join("\n"))
  end
end