Method: Cyperful::Driver#reset_steps

Defined in:
lib/cyperful/driver.rb

#reset_stepsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cyperful/driver.rb', line 76

def reset_steps
  # TODO: memoize this when there's multiple tests per file
  @steps =
    Cyperful::TestParser.new(@test_class).steps_per_test.fetch(@test_name)

  raise "No steps found in #{@test_class}:#{@test_name}" if @steps.blank?

  editor_scheme = config.editor_scheme

  @steps.each_with_index do |step, i|
    step.merge!(
      index: i,
      status: "pending",
      start_at: nil,
      end_at: nil,
      paused_at: nil,
      permalink:
        if editor_scheme && !editor_scheme.empty?
          "#{editor_scheme}://file/#{@source_filepath}:#{step.fetch(:line)}"
        end,
    )
  end

  # TODO: support multiple multiple steps per line, this takes only the last instance
  @step_per_line = @steps.index_by { |step| step[:line] }

  @current_step = nil

  @pause_at_step = true

  run_options = self.class.pop_run_options!
  if run_options.key?(:pause_at_step)
    @pause_at_step = run_options[:pause_at_step]
  end

  @test_result = nil

  # reset SCREENSHOTS_DIR
  FileUtils.rm_rf(SCREENSHOTS_DIR)
  FileUtils.mkdir_p(SCREENSHOTS_DIR)
end