Module: RSpecGherkin::DSL::Rspec

Defined in:
lib/rspec-gherkin/rspec-dsl.rb

Instance Method Summary collapse

Instance Method Details

#background(&block) ⇒ Object



56
57
58
# File 'lib/rspec-gherkin/rspec-dsl.rb', line 56

def background(&block)
  before(:each, &block)
end

#scenario(name = nil, new_metadata = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rspec-gherkin/rspec-dsl.rb', line 60

def scenario(name = nil,  = {}, &block)
  raise ArgumentError.new("requires a name") if name.nil?

  matching_scenario = find_scenario(self.[:current_feature], name)

  if matching_scenario
    if matching_scenario.tags.include?('updated')
      pending_scenario(name, , block.source_location, [
        "Scenario has been marked as updated",
        "Update specs for this scenario and remove the @updated tag",
        "Feature file: '#{feature_path(block.source_location)}'"
      ])
    elsif matching_scenario.arguments
      specify "Scenario: #{name}",  do
        instance_exec(*matching_scenario.arguments, &block)
      end
    else
      specify("Scenario: #{name}", , &block)
    end
  else
    pending_scenario(name, , block.source_location,
      "No such scenario in '#{feature_path(block.source_location)}'"
    )
  end
end