[英]Capybara Acceptance Tests: undefined method `visit' for #<RSpec::Core::ExampleGroup
I'm in the process of upgrading an old krufty application to Rails 3.1. 我正在将旧的krufty应用程序升级到Rails 3.1。 The company has been using RSpec and Capybara for acceptance tests.
该公司一直在使用RSpec和Capybara进行验收测试。 We've got some acceptance tests under
spec/acceptance
that are failing with the following message: 我们已经按照
spec/acceptance
验收进行了一些验收测试,但失败,并显示以下消息:
Failure/Error: get @url
NoMethodError:
undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007feb7c0abf58>
Here's an example of one of the tests (from the top of the file): 这是其中一个测试的示例(从文件顶部开始):
require_relative 'acceptance_helper'
feature 'Catalog' do
before do
Settings.use_catalog_navigation = true
end
context 'with a Vendor' do
before do
@vendor = create(:vendor, slug: 'abc')
@product = create(:product_with_variants, vendor: @vendor)
@non_vendor_product = create(:product_with_variants)
@invisible_product = create(:product_with_variants,
vendor: @vendor,
visible: false)
@non_available_product = create(:product_with_variants,
vendor: @vendor,
available: false)
@url = "/#{@vendor.slug}"
end
it 'sets @vendor' do # <- FIRST FAILING TEST
get @url
assigns(:vendor).should == @vendor
end
...
When consulting the oracle, I keep stumbling across issues mentioning the 'visit' method such as this: https://github.com/jnicklas/capybara/issues/814 在咨询oracle时,我总是在提到“访问”方法的问题上绊脚石,例如: https : //github.com/jnicklas/capybara/issues/814
I also keep coming across posts related to this article: http://alindeman.github.com/2012/11/11/rspec-rails-and-capybara-2.0-what-you-need-to-know.html 我还不断遇到与本文相关的帖子: http : //alindeman.github.com/2012/11/11/rspec-rails-and-capybara-2.0-what-you-need-to-know.html
I'm not sure that I'm having the same issue. 我不确定是否遇到相同的问题。 I can post my
spec_helper.rb
and acceptance_helper.rb
if they will be of any use. 如果可以使用,我可以发布我的
spec_helper.rb
和acceptance_helper.rb
。
I guess it's worth noting that these specs passed before I updated rspec-rails and capybara. 我想值得注意的是,这些规格在我更新rspec-rails和capybara之前已经通过。
My gut feeling is that perhaps rspec-rails is clobbering some of capybara's methods, or some of capybara's methods are simply no longer being loaded. 我的直觉是,也许rspec-rails破坏了capybara的某些方法,或者只是不再加载某些capybara的方法。 Could that be the issue?
这可能是问题吗?
Try and add config.include Capybara::DSL
in spec_helper.rb
, inside the config block. 尝试在config块内的
spec_helper.rb
添加config.include Capybara::DSL
spec_helper.rb
config.include Capybara::DSL
。 like so: 像这样:
RSpec.configure do |config|
config.include Capybara::DSL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.