./features/adding.feature
Feature: Adding
Scenario Outline: Add two numbers
Given the input "<input>"
When the adding is run
Then the output should be "<output>"
Examples:
| input | output |
| 2+2 | 4 |
| 98+1 | 99 |
加法源码:
./ calc.rb
print eval(ARGV[0])
Step definitions:
./features/step_definitions/calculaor_steps.rb
Given /^the input "([^"]*)"$/ do |input|
@input = input
end
When /^the adding is run$/ do
@output = `ruby calc.rb #{@input}`
raise('Command failed!') unless $?.success?
end
Then /^the output should be "([^"]*)"$/ do |expected_output|
@output.should == expected_output
end