Cucumber/Capybara/Selenium-Webdriver 错误?

发布于 2024-12-27 16:52:41 字数 705 浏览 1 评论 0原文

我最近升级到 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 技术交流群。

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

发布评论

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

评论(1

蓝天白云 2025-01-03 16:52:41

我使用 pry 找到了类似的问题。

[1] pry(#<Cucumber::Rails::World>)> step %{I go to login}
ArgumentError: wrong number of arguments (2 for 1)
from ~/.rvm/gems/ruby-1.8.7-p352/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in 'parse'

这是用 gem 'json', :require => 修复的在我的 Gemfile 中,'json/pure' 位于 bson 之前。

编辑:看起来还需要强制使用 1.9.2 (rvm --rvmrc --create 1.9.2)。

I tracked down a similar problem using pry.

[1] pry(#<Cucumber::Rails::World>)> step %{I go to login}
ArgumentError: wrong number of arguments (2 for 1)
from ~/.rvm/gems/ruby-1.8.7-p352/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in 'parse'

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).

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