Creating Step Definitions
Without thinking too much about what they mean, let’s just copy and paste the snippets from Cucumber’s last output into a Ruby file. Just like the features, Cucumber is expecting the step definitions to be found in a conventional place:
| $ mkdir features/step_definitions |
Now create a Ruby file in features/step_definitions, called calculator_steps.rb. Cucumber won’t mind what you call it as long as it’s a Ruby file, but this is a good name to use. Open it in your text editor and paste in those snippets:
first_taste/02/features/step_definitions/calculator_steps.rb | |
| Given /^the input "([^"]*)"$/ do |arg1| |
| pending # express the regexp above with the code you wish you had |
| end |
| |
| When /^the calculator is run$/ ... |
Get The Cucumber Book now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.