class Gurke::Step

Attributes

file[R]

Return path to file containing this scenario.

@return [String] File path.

line[R]

Return line number where the scenario is defined.

@return [Fixnum] Line number.

raw[R]

@api private

type[R]

Public Class Methods

new(file, line, type, raw) click to toggle source

@api private

# File lib/gurke/step.rb, line 24
def initialize(file, line, type, raw)
  @file = file
  @line = line
  @type = type
  @raw = raw
end

Public Instance Methods

doc_string() click to toggle source
# File lib/gurke/step.rb, line 40
def doc_string
  raw.doc_string&.value
end
keyword() click to toggle source
# File lib/gurke/step.rb, line 36
def keyword
  raw.keyword.strip
end
name() click to toggle source
# File lib/gurke/step.rb, line 31
def name
  raw.name
end
Also aliased as: to_s
run(runner, reporter, scenario, world) click to toggle source

@api private

# File lib/gurke/step.rb, line 46
def run(runner, reporter, scenario, world)
  reporter.invoke :before_step, self, scenario

  result = runner.hook(:step, self, world) do
    run_step runner, reporter, scenario, world
  end

  reporter.invoke :after_step, result, scenario
end
to_s()
Alias for: name

Private Instance Methods

find_and_run_step(runner, scenario, world) click to toggle source
# File lib/gurke/step.rb, line 76
def find_and_run_step(runner, scenario, world)
  runner.with_filtered_backtrace do
    match = Steps.find_step self, world, type

    if scenario.pending? || scenario.failed? || scenario.aborted?
      return StepResult.new self, scenario, :skipped
    end

    m = world.method match.method_name
    world.send match.method_name, *(match.params + [self])[0...m.arity]

    StepResult.new self, scenario, :passed
  end
end
run_step(runner, reporter, scenario, world) click to toggle source
# File lib/gurke/step.rb, line 58
def run_step(runner, reporter, scenario, world)
  reporter.invoke :start_step, self, scenario

  result = find_and_run_step runner, scenario, world
rescue Interrupt
  scenario.abort!
  result = StepResult.new self, scenario, :aborted
  raise
rescue StepPending => e
  scenario.pending! e
  result = StepResult.new self, scenario, :pending, e
rescue Exception => e # rubocop:disable RescueException
  scenario.failed! e
  result = StepResult.new self, scenario, :failed, e
ensure
  reporter.invoke :end_step, result, scenario
end