Created
November 9, 2023 07:50
-
-
Save Niall47/e8385872b47c07a196f91f619e1c6b72 to your computer and use it in GitHub Desktop.
Ruby Cucumber ParameterTypes example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomerScenario | |
| def initialize(scenario) | |
| @scenario = scenario | |
| end | |
| end | |
| ParameterType( | |
| name: 'customer_scenario', | |
| regexp: /passed|failed|banned/, | |
| type: CustomerScenario, | |
| transformer: ->(s) { CustomerScenario.new(s) } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Feature: parameter types | |
| Scenario: | |
| Given I have a customer with status: banned |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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