1

これはキュウリのスクリプト エラーです。期待値と取得値が異なることは理解していますが、これを解決する方法がわかりません。

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:'

機能ファイル: four.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 |

ステップの定義: four_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]) 
4

1 に答える 1

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
于 2013-09-16T16:37:09.797 に答える