[英]rspec capybara error - undefined method `visit' for #<RSpec
我有:
已將gem 'capybara'
添加到我的Gemfile
並且我運行了bundle
已將我的規范作為visit_home_page_root_spec.rb
放入規范/請求中
已添加到`spec / spec_helper.rb:
--
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
但我仍然收到標題中顯示的消息。
我的規格是:
describe "Home Page", :type => :feature do
it "Visit the home page" do
visit '/'
expect(page).to have_content 'Linker'
end
end
Gemfile.lock
具有:
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.1)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
聽起來您的示例中沒有包含水豚DSL。 這已經越來越少地自動完成了(在rspec 3中一點也不做),但是從內存來看應該是您的版本。
不過,您應該可以通過以下方式對此進行補救
describe "foo" do
include Capybara::DSL
end
對於任何需要它的規格。 或者,在您的RSpec.configure
塊中,執行
config.include(Capybara::DSL, :type => :feature)
會針對所有類型的功能自動執行此操作)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.