Class: Spinach::Reporter::Rerun

Inherits:
Stdout
  • Object
show all
Defined in:
lib/spinach/reporter/rerun.rb

Instance Method Summary collapse

Instance Method Details

#after_run(success) ⇒ Object



17
18
19
20
21
22
# File 'lib/spinach/reporter/rerun.rb', line 17

def after_run(success)
  super success

  # save rerun scenarios in a file
  File.open(rerun_file, 'w') { |f| f.write @rerun.join("\n") } unless success
end

#before_run(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/spinach/reporter/rerun.rb', line 4

def before_run(*args)
  super(*args)

  # reset rerun.txt file
  File.delete(rerun_file) if File.file?(rerun_file)

  # create tmp folder if not exists
  Dir.mkdir('tmp', 0o755) unless Dir.exist?('tmp')

  # rerun list of failing scenarios
  @rerun = []
end

#on_error_step(step, failure, step_location, step_definitions = nil) ⇒ Object



31
32
33
34
35
36
# File 'lib/spinach/reporter/rerun.rb', line 31

def on_error_step(step, failure, step_location, step_definitions=nil)
  super step, failure, step_location, step_definitions

  # save feature file and scenario line
  @rerun << "#{current_feature.filename}:#{current_scenario.lines[0]}"
end

#on_failed_step(step, failure, step_location, step_definitions = nil) ⇒ Object



24
25
26
27
28
29
# File 'lib/spinach/reporter/rerun.rb', line 24

def on_failed_step(step, failure, step_location, step_definitions=nil)
  super step, failure, step_location, step_definitions

  # save feature file and scenario line
  @rerun << "#{current_feature.filename}:#{current_scenario.lines[0]}"
end