Module: KanoahRSpecFormatter::Example

Defined in:
lib/kanoah_rspec_formatter/rspec_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
# File 'lib/kanoah_rspec_formatter/rspec_steps.rb', line 3

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