2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】RspecでCapybaraを使用した際に「undefined method `visit'」というエラーが出た場合の解決方法

Last updated at Posted at 2020-07-12

開発環境

・Ruby: 2.5.7
・Rails: 5.2.4
・rspec-rails: 4.0.1
・Capybara: 3.32.2
・Vagrant: 2.2.7
・VirtualBox: 6.1
・OS: macOS Catalina

原因

Capybaraが読み込めていない。

解決方法

1.requireで読み込む

spec_helper.rb
require 'capybara/rspec' # 追記
RSpec.configure do |config|
end

2. 解決方法1で解決しない場合はDSLで強制的に読み込む

spec_helper.rb
require 'capybara/rspec'
RSpec.configure do |config|
  config.include Capybara::DSL # 追記
end
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?