“eval”已弃用。请改用“评估”

时间:2013-04-06 19:38:42

标签: ruby-on-rails ruby linux cucumber

最近写黄瓜功能我收到警告

[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead

一切正常,但这个警告让我感到不安。我正在使用 Rails 3.1.0 ruby​​ 1.9.3p392(2013-02-22修订版39386)[x86_64-linux] 。我的文件是:

item.feature:

Background: logged in as an admin
Given I am logged in as an administrator

user_steps.rb

 Given /^I am logged in as an administrator$/ do
 steps %Q{
   Given the following users exist:
    | email               | password         | role       |
    | admin@test.com      | admin_password   | admin      |
    | visitor@visitor.com | visitor_password | registered |
   And I am on the "home page"
   And I follow "Login"
   And I fill in "Email" with "admin@test.com"
   And I fill in "Password" with "admin_password"
   And I press "Sign in"
   Then I should see "admin"
}
end

因此我有:

 Background: logged in as an admin            # features/item.feature:6
[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead
[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead
[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead
[DEPRECATION] "eval" is deprecated. Please use "evaluate" instead

1 个答案:

答案 0 :(得分:8)

进入完全相同的问题。它没有破坏任何东西,它只是丑陋。

似乎代码不匹配。 Gherkin已弃用eval而赞成evaluate,而Cucumber正在调用旧方法。已经准备好拉取请求并a closed issue for this on github

直到更新Cucumber之前最快最简单的解决方案是将此行添加到您的Gemfile中:

gem 'gherkin', '<= 2.11.6'

这将迫使小黄瓜回到eval被弃用之前的时间。

修改

黄瓜宝石似乎已经更新,不再产生弃用警告。