我正在尝试在“黄瓜书”一书中的计算器项目中执行第 2 步。我已尝试按照此表单中给出的先前答案使用反技巧而不是单引号,但我仍然收到以下相同的错误消息:
.F-
(::) failed steps (::)
undefined method `success?' for nil:NilClass (NoMethodError)
./features/step_definitions/calculator_steps.rb:7:in `/^the calculator is run$/'
features/adding.feature:5:in `When the calculator is run'
Failing Scenarios:
cucumber features/adding.feature:3 # Scenario: Add two numbers
1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
0m0.002s
这是我之前在您的论坛上找到的确切步骤信息:
Given /^the input "([^"]*)"$/ do |input|
@input = input
end
When /^the calculator is run$/ do
@output = `ruby calc.rb #{@input}`
raise('Command failed!') unless $?.success?
end
Then /^the output should be "([^"]*)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end
我做错了什么?