未定义的局部变量或方法“页面”对于 Cucumber::Rails::World (NameError)
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对 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.
修正了错误。 我注释掉了:
由于之前的问题, 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.