Module: Turnip::RSpec::Execute

Includes:
Execute
Defined in:
lib/turnip/rspec.rb

Overview

This module provides an improved method to run steps inside RSpec, adding proper support for pending steps, as well as nicer backtraces.

Instance Method Summary collapse

Methods included from Execute

#step

Instance Method Details

#run_step(feature_file, step) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/turnip/rspec.rb', line 42

def run_step(feature_file, step)
  begin
    instance_eval <<-EOS, feature_file, step.line
      step(step)
    EOS
  rescue Turnip::Pending => e
    example = ::RSpec.current_example
    example.[:line_number] = step.line
    example.[:location] = "#{example.[:file_path]}:#{step.line}"

    if ::RSpec.configuration.raise_error_for_unimplemented_steps
      e.backtrace.push "#{feature_file}:#{step.line}:in `#{step.description}'"
      raise
    end

    skip("No such step: '#{e}'")
  rescue StandardError, ::RSpec::Expectations::ExpectationNotMetError => e
    e.backtrace.push "#{feature_file}:#{step.line}:in `#{step.description}'"
    raise e
  end
end