Module: ATMFormatter::Example

Defined in:
lib/atm_formatter/steps.rb

Instance Method Summary collapse

Instance Method Details

#step(step, _options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/atm_formatter/steps.rb', line 3

def step(step, _options = {}, &block)
  @metadata[:steps] = [] if @metadata[:steps].nil?
  if RSpec.configuration.dry_run?
    @metadata[:steps].push(step_name: step, index: @metadata[:step_index])
  else
    begin
      yield block
      @metadata[:steps].push(step_name: step, index: @metadata[:step_index], status: 'Pass')
    rescue => e
      @metadata[:steps].push(step_name: step, index: @metadata[:step_index], status: 'Fail', comment: process_exception(e))
      raise
    end
  end
ensure @metadata[:step_index] += 1 if @metadata.key?(:step_index)
end