Created
November 28, 2017 15:12
-
-
Save aslakhellesoy/017fc05cf7e1be9d122caf54082b7dc3 to your computer and use it in GitHub Desktop.
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
# features/support/parameter_types.rb | |
suffix = '(?:st|nd|rd|th)' | |
ParameterType( | |
name: 'flight', | |
regexp: /(\d+)#{suffix} flight/, | |
transformer: ->(n) { n.to_i } | |
) | |
ParameterType( | |
name: 'hotel', | |
regexp: /(\d+)#{suffix} hotel/, | |
transformer: ->(n) { n.to_i } | |
) |
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
# features/travel.feature | |
Feature: Travel | |
Scenario Outline: optional-flight & optional-hotel | |
Given <query> | |
Examples: | |
| query | | |
| I reach StageFour: 3rd flight-2nd hotel test | | |
| I reach StageFour: 3rd hotel test | | |
| I reach StageFour: 17th flight test | | |
| I reach StageFive: 2nd flight-1st hotel test | | |
| I reach StageFive: 44th hotel test | | |
| I reach StageFive: 11th flight test | |
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
# featrures/step_definitions/travel_steps.rb | |
Given('I reach StageFour:/StageFive: {flight}-{hotel} test') do |flight_number, hotel_number| | |
flight_and_hotel(flight_number, hotel_number) | |
end | |
Given('I reach StageFour:/StageFive: {flight} test') do |flight_number| | |
flight_and_hotel(flight_number, nil) | |
end | |
Given('I reach StageFour:/StageFive: {hotel} test') do |hotel_number| | |
flight_and_hotel(nil, hotel_number) | |
end | |
module TravelWorld | |
def flight_and_hotel(flight, hotel) | |
puts "Flight #{flight} - Hotel #{hotel}" | |
end | |
end | |
World(TravelWorld) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment