class Lopata::StepExecution

@private

Attributes

block[R]
exception[R]
groups[R]
pending_message[R]
status[R]
step[R]

Public Class Methods

new(step, groups, &block) click to toggle source
# File lib/lopata/step.rb, line 110
def initialize(step, groups, &block)
  @step = step
  @status = :not_runned
  @exception = nil
  @block = block
  @groups = groups
end

Public Instance Methods

failed?() click to toggle source
# File lib/lopata/step.rb, line 144
def failed?
  status == :failed
end
let_methods() click to toggle source

Step methods is a combination of let_methods for all contexts (group) the step included

# File lib/lopata/step.rb, line 187
def let_methods
  (groups).compact.inject({}) { |merged, part| merged.merge(part.let_methods) }
end
metadata() click to toggle source

Step metadata is a combination of metadata given for step and all contexts (groups) the step included

# File lib/lopata/step.rb, line 182
def metadata
  (groups + [step]).compact.inject({}) { |merged, part| merged.merge(part.metadata) }
end
passed?() click to toggle source
# File lib/lopata/step.rb, line 148
def passed?
  status == :passed
end
pending!(message = nil) click to toggle source
# File lib/lopata/step.rb, line 164
def pending!(message = nil)
  @status = :pending
  @pending_message = message
end
pending?() click to toggle source
# File lib/lopata/step.rb, line 160
def pending?
  status == :pending
end
run(scenario) click to toggle source
# File lib/lopata/step.rb, line 123
def run(scenario)
  @status = :running
  begin
    run_step(scenario)
    if pending?
      @status = :failed
      raise PendingStepFixedError, 'Expected step to fail since it is pending, but it passed.'
    else
      @status = :passed
    end
  rescue Exception => e
    @status = :failed unless pending?
    @exception = e
  end
end
run_step(scenario) click to toggle source
# File lib/lopata/step.rb, line 139
def run_step(scenario)
  return unless block
  scenario.instance_exec(&block)
end
skip!() click to toggle source
# File lib/lopata/step.rb, line 156
def skip!
  @status = :skipped
end
skip_rest_on_failure?() click to toggle source
# File lib/lopata/step.rb, line 177
def skip_rest_on_failure?
  %i{ setup action }.include?(method_name)
end
skipped?() click to toggle source
# File lib/lopata/step.rb, line 152
def skipped?
  status == :skipped
end
teardown?() click to toggle source
# File lib/lopata/step.rb, line 169
def teardown?
  %i{ teardown cleanup }.include?(method_name)
end
teardown_group?(group = nil) click to toggle source
# File lib/lopata/step.rb, line 173
def teardown_group?(group = nil)
  teardown? && self.groups.last == group
end
title() click to toggle source
# File lib/lopata/step.rb, line 118
def title
  group_title = groups.map { |g| "#{g.title}: " }.join
  "#{group_title}#{step.title}"
end