7

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

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

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

项目特征:

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

用户步骤.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
4

1 回答 1

8

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

这似乎是代码不匹配。Gherkin 已弃用evalevaluateCucumber 正在调用旧方法。在 github 上已经准备好了一个 pull request 和一个已关闭的 issue

在 Cucumber 可能很快更新之前,最快和最简单的解决方案就是将这一行添加到您的 Gemfile 中:

gem 'gherkin', '<= 2.11.6'

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

编辑:

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

于 2013-04-06T20:23:25.927 回答