未定义的局部变量或方法“页面”对于 Cucumber::Rails::World (NameError)

发布于 2024-11-03 09:50:39 字数 582 浏览 1 评论 0原文

我正在 cygwin 环境中使用 Rspec 2.5.0 和 Cucumber-rails 0.4.1 按照 RBates RailsCasts 教程运行基本功能。我正处于测试“然后我应该看到”的步骤

,例如:

Scenario: Stores List
    Given I have stores named Pizza, Breadsticks
    When I go to the list of stores
    **Then I should see "Pizza"**

运行黄瓜功能会给我以下错误消息:

未定义的局部变量或方法'页面' for Cucumber::Rails::World (NameError)

然后我应该请参阅 web_steps 文件中的定义如下:

 if page.respond_to? :should
    page.should have_content(text)
  else
    assert page.has_content?(text)
  end

任何指导将不胜感激!

谢谢你!

I'm running a basic feature by following RBates RailsCasts tutorial using Rspec 2.5.0 and Cucumber-rails 0.4.1 on a cygwin environment. I am at the step where I am testing "Then I should see"

For example:

Scenario: Stores List
    Given I have stores named Pizza, Breadsticks
    When I go to the list of stores
    **Then I should see "Pizza"**

Running cucumber features gives me the following error message:

Undefined local variable or method 'page' for Cucumber::Rails::World (NameError)

Then I should See is defined in the web_steps file as follows:

 if page.respond_to? :should
    page.should have_content(text)
  else
    assert page.has_content?(text)
  end

Any guidance would be appreciated!

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过度放纵 2024-11-10 09:50:40

我对 RoR 不太了解,并且没有看到更多代码,看来您还没有定义变量“page”,或者您在尝试使用它的范围之外的区域中定义了它。

I don't know much of RoR, and without seeing more code, it appears you haven't defined the variable 'page', or you defined it in an area that is outside the scope of where you're trying to use it.

生生漫 2024-11-10 09:50:39

修正了错误。 我注释掉了:

由于之前的问题, Capybara.default_selector = :css (请参阅: https: //github.com/aslakhellesoy/cucumber-rails/issues/120)。一旦我包含以下内容:

需要“capybara/rails”
require 'capybara/cucumber'

修复了水豚问题,页面方法可用。

谢谢。

Fixed the error. I had commented out:

Capybara.default_selector = :css because of a previous issue (See: https://github.com/aslakhellesoy/cucumber-rails/issues/120). Once i included the following:

require 'capybara/rails'
require 'capybara/cucumber'

It fixed the capybara issue and the page method was available.

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文