如何解决此ExpectationNotMetError错误

RubyNoobie

这是我的黄瓜脚本错误。尽管我知道期望值和获得的值是不同的,但我不知道该如何解决。

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

功能文件:third.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]) 
巴拉

尝试这个。更改

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何解决此ExpectationNotMetError错误

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此错误?

来自分类Dev

如何解决此错误:分段错误?

来自分类Dev

如何解决此错误--dbWriteTable()

来自分类Dev

如何解决此“ OutOfBoundaryException”错误?

来自分类Dev

在MiniZinc中如何解决此错误?

来自分类Dev

如何解决此OOP错误?

来自分类Dev

如何解决此rstrip属性错误?

来自分类Dev

如何解决此PHP通知错误?

来自分类Dev

如何解决此错误并安装cocoapods?

来自分类Dev

您如何解决此错误

来自分类Dev

如何解决此属性错误?

来自分类Dev

如何解决此OOP错误?

来自分类Dev

如何解决此Eclipse错误?

来自分类Dev

如何解决此验证错误?

来自分类Dev

如何解决此httpProvider错误?

来自分类Dev

如何解决此linphone $ make错误?

来自分类Dev

如何解决此JTextArea格式错误?

来自分类Dev

此查询中的错误:如何解决?

来自分类Dev

如何解决此升级错误?

来自分类Dev

如何解决此错误?“ assign”附近的语法错误

来自分类Dev

如何解决有此makeHttpRequest错误的错误?

来自分类Dev

在ubuntu上安装devstackkg时如何解决此错误

来自分类Dev

如何解决magento1.9.1.0此错误

来自分类Dev

从Gradle发布到Nexus时如何解决此错误

来自分类Dev

如何解决Java 8中的此错误?

来自分类Dev

如何解决此边缘迭代器分配错误?