这是我的黄瓜脚本错误。虽然我明白预期和得到的价值是不同的,但我不知道如何解决这个问题。
Then my output should be: # features/step_definitions/fourth_steps.rb:10
| 4 |
expected: ["4"]
got: "[4]" (using ==) (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/fourth_steps.rb:11:in `/^my output should be:$/'
features\fourth.feature:6:in `Then my output should be:'
特征文件:fourth.feature
Feature: Cucumber Exercises
Scenario: Try data table for the first exercises
Given I have these numberic operations:
|2+2|
When calculator is run
Then my output should be:
| 4 |
步骤定义:fourth_steps.rb
Given(/^I have these numberic operations:$/) do |table|
@input = table.raw.flatten
end
When(/^calculator is run$/) do
@output = `ruby calc.rb #{@input}`
raise ("calc.rb did not run properly.") unless $?.success?
end
Then(/^my output should be:$/) do |table|
@output.should == table.raw.flatten
end
calc.rb
print eval (ARGV[0])
答案 0 :(得分:0)
试试这个。变化
When(/^calculator is run$/) do
@output = `ruby calc.rb #{@input}`
raise ("calc.rb did not run properly.") unless $?.success?
end
到
When(/^calculator is run$/) do
@output = []
@input.each { |i| @output << `ruby calc.rb #{i}`}
raise ("calc.rb did not run properly.") unless $?.success?
end