Cucumber/Capybara/Selenium-Webdriver 错误?
我最近升级到 Rails 3,并且正在尝试运行我的 Cucumber 测试。
当我运行测试时,出现以下错误:
wrong number of arguments (2 for 1) (ArgumentError)
./features/step_definitions/user_steps.rb:24:in `/^I am logged in$/'
features/account.feature:8:in `Given I am logged in'
此测试只是打开我的登录页面。当我的功能文件顶部不包含 @javascript 标志时,它运行正常。当我包含它时,我收到错误,Selenium(我认为)打开了 Firefox 的实例,但浏览器中没有任何反应。
编辑:
我的“我已登录”步骤如下所示:
Given /^I am logged in$/ do
@user = Factory(:user, :email => "[email protected]")
@user.activate
visit path_to("the login page")
end
I've recently upgraded to Rails 3 and I'm trying to get my Cucumber tests to run.
When I run the tests, I'm getting the following error:
wrong number of arguments (2 for 1) (ArgumentError)
./features/step_definitions/user_steps.rb:24:in `/^I am logged in$/'
features/account.feature:8:in `Given I am logged in'
This test does nothing more than opening my login page. When I don't include the @javascript flag at the top of my feature file, it runs fine. When I do include it, I get the error and Selenium (I think) opens an instance of Firefox but nothing happens in the browser.
EDIT:
My I am logged in step looks like this:
Given /^I am logged in$/ do
@user = Factory(:user, :email => "[email protected]")
@user.activate
visit path_to("the login page")
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 pry 找到了类似的问题。
这是用 gem 'json', :require => 修复的在我的 Gemfile 中,'json/pure' 位于 bson 之前。
编辑:看起来还需要强制使用 1.9.2 (
rvm --rvmrc --create 1.9.2
)。I tracked down a similar problem using pry.
Which was fixed with
gem 'json', :require => 'json/pure'
ahead of bson in my Gemfile.Edit: Look like it was also necessary to force use of 1.9.2 (
rvm --rvmrc --create 1.9.2
).