January 2012
Intermediate to advanced
336 pages
8h 12m
English
To implement the next step, edit features/step_definitions/calculator_steps.rb so that the second step definition looks like this:
| first_taste/04/features/step_definitions/calculator_steps.rb | |
| | When /^the calculator is run$/ do |
| | @output = `ruby calc.rb #{@input}` |
| | raise('Command failed!') unless $?.success? |
| | end |
This code attempts to run our calculator program calc.rb, passing it the input we stored in the first step and storing any output in another instance variable. Then it checks a specially—but rather cryptically—named Ruby variable $? to check whether the command succeeded and raises an error if it didn’t. Remember that Cucumber fails a step if the step definition raises an error; this is the simplest way ...
Read now
Unlock full access