LoginSignup
5
6

More than 5 years have passed since last update.

RSpec3.2でCapypara使ってて undefined method `visit’と出る時

Last updated at Posted at 2015-02-08

railstutorial3章を消化しててぶつかったところのメモ。
今使ってるrspecのバージョンが3.2だからか、rails generate integration_test static_pages で出力されるrspecコードが記載と異なっている。

そのまま動かすと、「undefined method `visit’」と出る。

対処法は、こちらのページを参考
Capyparaで undefined method visit’と出る時の対処法

Gemfile
group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.2.0' #2.2.0に修正
end
spec/rails_helper.rb
#以下を追記
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)

require 'rspec/rails'
require 'capybara/rspec'
require 'rspec/autorun'

RSpec.configure do |config|
  ()
  config.include Capybara::DSL
end

取り敢えずこの対応で、
bundle exec rspec spec/requests/static_pages_spec.rb
は動いた。

5
6
1

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
5
6