Home>

Thank you for browsing!

Currently, I am developing an original application on rails, but rspec does not start and it is stuck.
Looking at the error content, I could guess that the cause was that require'capybara/rspec' was not loaded, but I could not solve it. .. ..

The environment is as follows.
・ Mac os

・ Ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]

・ Rails -v
Rails 6.0.3.4

・ Rspec -v
RSpec 3.10

  • rspec-core 3.10.0
  • rspec-expectations 3.10.0
  • rspec-mocks 3.10.0
  • rspec-support 3.10.0

Thanks for your cooperation.

bin/rspec
An error occurred while loading ./spec/helpers/application_helper_spec.rb.
Failure/Error: require'capybara/rspec'
LoadError:
  cannot load such file --capybara/rspec
# ./spec/rails_helper.rb: 1: in `<top (required)>'
# ./spec/helpers/application_helper_spec.rb: 1: in `<top (required)>'
An error occurred while loading ./spec/requests/static_pages_spec.rb. --Did you mean?
                    rspec ./spec/system/static_pages_spec.rb
Failure/Error: require'capybara/rspec'
LoadError:
  cannot load such file --capybara/rspec
# ./spec/rails_helper.rb: 1: in `<top (required)>'
# ./spec/requests/static_pages_spec.rb: 1: in `<top (required)>'
An error occurred while loading ./spec/system/static_pages_spec.rb. --Did you mean?
                    rspec ./spec/requests/static_pages_spec.rb
Failure/Error: require'capybara/rspec'
LoadError:
  cannot load such file --capybara/rspec
# ./spec/rails_helper.rb: 1: in `<top (required)>'
# ./spec/system/static_pages_spec.rb: 1: in `<top (required)>'
No examples found.
Finished in 0.00003 seconds (files took 0.12944 seconds to load)
0 examples, 0 failures, 3 errors occurred outside of examples


spec/rails_helper.rb

require'capybara/rspec'
require'spec_helper'
Dir [Rails.root.join ('spec/support/**/*. Rb')]. each {| f | require f}
ENV ['RAILS_ENV'] || ='test'
require File.expand_path ('../ config/environment', __dir__)
abort ("The Rails environment is running in production mode!") if Rails.env.production?
require'rspec/rails'
begin begin
  ActiveRecord :: Migration.maintain_test_schema!
rescue ActiveRecord :: PendingMigrationError =>e
  puts e.to_s.strip
  exit 1
end
RSpec.configure do | config |
  config.include Devise :: Test :: IntegrationHelpers, type :: system
  config.fixture_path = "# {:: Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true
  config.infer_spec_type_from_file_location!
  config.filter_rails_from_backtrace!
end
source'https://rubygems.org'
git_source (: github) {| repo | "https://github.com/#{repo}.git"}
ruby '2.6.6'
gem'rails','~>6.0.3','>= 6.0.3.3'
gem'puma','~>4.1'
gem'sass-rails','>= 6'
gem'webpacker','~>4.0'
gem'turbolinks','~>5'
gem'jbuilder','~>2.7'
gem'bootsnap'
gem'bootstrap-sass'
gem'devise'
group: development,: test do
  gem'sqlite3','~>1.4'
  gem'rails-controller-testing'
  gem'rspec-rails'
  gem'byebug', platforms: [: mri,: mingw,: x64_mingw]
end
group: development do
  gem'spring-commands-rspec'
  gem'web-console','>= 3.3.0'
  gem'listen','~>3.2'
  gem'spring'
  gem'spring-watcher-listen','~>2.0.0'
end
group: test do
  gem'webdrivers'
  gem'capybara','>= 2.15'
  gem'selenium-webdriver'
  gem'webdrivers'
end
group: production do
  gem'pg'
end
gem'tzinfo-data'