Skip to content

Instantly share code, notes, and snippets.

@Niall47
Created November 9, 2023 07:50
Show Gist options
  • Save Niall47/e8385872b47c07a196f91f619e1c6b72 to your computer and use it in GitHub Desktop.
Save Niall47/e8385872b47c07a196f91f619e1c6b72 to your computer and use it in GitHub Desktop.
Ruby Cucumber ParameterTypes example
class CustomerScenario
def initialize(scenario)
@scenario = scenario
end
end
ParameterType(
name: 'customer_scenario',
regexp: /passed|failed|banned/,
type: CustomerScenario,
transformer: ->(s) { CustomerScenario.new(s) }
)
Feature: parameter types
Scenario:
Given I have a customer with status: banned
Given('I have a customer with status: {customer_scenario}') do |customer_scenario|
# Here we recieve a CustomerScenario object which allows us to call customer_scenario.scenario
puts customer_scenario.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment