Capybara select 语句不适用于 Rspec
将 Capybara 与 Rails 3、Rspec 和 Cucumber 一起使用,
当我使用 select 语句时,例如
select("Unspecified", :from=> 'record_family_')
我收到错误,参数数量错误 (2 for 3)
。同样,如果我省略第二个参数,我会得到错误的参数数量(1 代表 3)。无论我使用 RSpec 还是 Cucumber,都会发生这种情况。如果我切换到 Webrat,一切都会正常。
详细信息:Rails 3.0.4、rspec-core 2.5.1、rspec-rails 2.5.0、capybara 0.1.4.2、rack 1.2.1
堆栈跟踪的前几行(路径简化)是:
wrong number of arguments (1 for 3) (ArgumentError)
actionpack-3.0.5/lib/action_view/helpers/form_options_helper.rb:131:in `select'
capybara-0.4.1.2/lib/capybara/dsl.rb:104:in `select'
step_definitions/sim_db_steps.rb:412:in `block in <top (required)>'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
cucumber-0.10.0/lib/cucumber/rb_support/rb_step_definition.rb:62:in `invoke'
有什么想法吗?
Using Capybara with Rails 3, Rspec and Cucumber,
When I use the select statement, such as
select("Unspecified", :from=> 'record_family_')
I get an error, wrong number of arguments (2 for 3)
. Likewise, if I omit the second argument, I get wrong number of arguments (1 for 3)
. This happens whether I'm using RSpec or Cucumber. If I switch to Webrat, everything works.
Details: Rails 3.0.4, rspec-core 2.5.1, rspec-rails 2.5.0, capybara 0.1.4.2, rack 1.2.1
The first few lines of the stack trace (with the path simplified) are:
wrong number of arguments (1 for 3) (ArgumentError)
actionpack-3.0.5/lib/action_view/helpers/form_options_helper.rb:131:in `select'
capybara-0.4.1.2/lib/capybara/dsl.rb:104:in `select'
step_definitions/sim_db_steps.rb:412:in `block in <top (required)>'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
cucumber-0.10.0/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
cucumber-0.10.0/lib/cucumber/rb_support/rb_step_definition.rb:62:in `invoke'
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢 Jonas Niklas 指出了这个问题,即名称空间问题。我间接将
ActionView::Helpers::FormOptionsHelper
包含到测试用例中,以便 ActionViewselect
与 Capybara 发生冲突。Thanks to Jonas Niklas for pointing out the problem, a name space issue. I had indirectly included
ActionView::Helpers::FormOptionsHelper
into the test cases so that the ActionViewselect
was conflicting with the Capybara one.我也遇到了 select 的名称空间问题(它使用 kernel 而不是 page.select)。我最终不得不改变这一点:
对此:
只需包含的顺序就可以修复它。
I had a name space issue also with select (it was using kernel instead of page.select). I ended up having to change this:
To this:
Just the ordering of the includes fixed it.