前提・実現したいこと
Rails、RSpecのテスト環境構築でつまづいています。
テストを実行しようとすると、1 error occurred outside of examplesのエラーが発生し、困っています。
Load Errorと出ているので、ファイルの名称や配置に問題があるとも考えられますが、
specフォルダは自動生成されたものを使っている為、誤りはないと考えております。
解決の糸口が掴めず、お力をお借りしたい次第です。
発生している問題・エラーメッセージ
hogehoge ./spec/models/item_spec.rb An error occurred while loading ./spec/models/item_spec.rb. - Did you mean? rspec ./spec/models/image_spec.rb rspec ./spec/models/size_spec.rb rspec ./spec/models/status_spec.rb Failure/Error: require File.expand_path('../config/environment', __dir__) LoadError: cannot load such file -- childprocess # ./config/application.rb:7:in `<top (required)>' # ./config/environment.rb:2:in `require_relative' # ./config/environment.rb:2:in `<top (required)>' # ./spec/rails_helper.rb:5:in `require' # ./spec/rails_helper.rb:5:in `<top (required)>' # ./spec/models/item_spec.rb:1:in `require' # ./spec/models/item_spec.rb:1:in `<top (required)>' No examples found. Finished in 0.00005 seconds (files took 1.4 seconds to load) 0 examples, 0 failures, 1 error occurred outside of examples
該当のソースコード
spec/models/item_spec.rb
Rails
1require 'rails_helper' 2 3RSpec.describe Item, type: :model do 4 pending "add some examples to (or delete) #{__FILE__}" 5end
spec/rails_helper.rb
Rails
1# This file is copied to spec/ when you run 'rails generate rspec:install' 2require 'spec_helper' 3ENV['RAILS_ENV'] ||= 'test' 4 5require File.expand_path('../config/environment', __dir__) 6require 'capibara/rspec' 7# Prevent database truncation if the environment is production 8abort("The Rails environment is running in production mode!") if Rails.env.production? 9require 'rspec/rails' 10# Add additional requires below this line. Rails is not loaded until this point!
config/environment.rb
Rails
1# Load the Rails application. 2require_relative 'application' 3 4# Initialize the Rails application. 5Rails.application.initialize!
Gemfile
Rails
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.5.1' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.3' 8# Use mysql as the database for Active Record 9gem 'mysql2', '>= 0.4.4', '< 0.6.0' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0' 14# Use Uglifier as compressor for JavaScript assets 15gem 'uglifier', '>= 1.3.0' 16# See https://github.com/rails/execjs#readme for more supported runtimes 17# gem 'mini_racer', platforms: :ruby 18 19# Use CoffeeScript for .coffee assets and views 20gem 'coffee-rails', '~> 4.2' 21# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 22 23# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24gem 'jbuilder', '~> 2.5' 25# Use Redis adapter to run Action Cable in production 26# gem 'redis', '~> 4.0' 27# Use ActiveModel has_secure_password 28# gem 'bcrypt', '~> 3.1.7' 29 30# Use ActiveStorage variant 31# gem 'mini_magick', '~> 4.8' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36# Reduces boot times through caching; required in config/boot.rb 37gem 'bootsnap', '>= 1.1.0', require: false 38 39group :development, :test do 40 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 42 gem 'rspec-rails' 43 gem 'factory_bot_rails' 44 gem 'rails-controller-testing' 45 gem 'faker' 46 gem 'capistrano' 47 gem 'capistrano-rbenv' 48 gem 'capistrano-bundler' 49 gem 'capistrano-rails' 50 gem 'capistrano3-unicorn' 51end 52 53group :development do 54 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 55 gem 'web-console', '>= 3.3.0' 56 gem 'listen', '>= 3.0.5', '< 3.2' 57 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 58 gem 'spring' 59 gem 'spring-watcher-listen', '~> 2.0.0' 60end 61 62group :test do 63 # Adds support for Capybara system testing and selenium driver 64 gem 'capybara', '>= 2.15' 65 gem 'selenium-webdriver' 66 # Easy installation and use of chromedriver to run system tests with Chrome 67 gem 'chromedriver-helper' 68end 69 70# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 71gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 72 73gem 'jquery-rails' 74gem 'haml-rails' 75gem 'font-awesome-sass' 76gem 'devise' 77gem 'erb2haml' 78gem 'carrierwave' 79gem 'mini_magick' 80gem 'pry-rails' 81gem 'fog-aws' 82gem 'sprockets-es6' 83 84group :production do 85 gem 'unicorn', '5.4.1' 86end
試したこと
Gemfileを削除した上でbundle install
データベースのリセット
rspec ./spec/models/image_spec.rb等、他のファイルでの実行。
補足情報(FW/ツールのバージョンなど)
ruby 2.5.1
Rails 5.2.4.1
RSpec 3.9
- rspec-core 3.9.1
- rspec-expectations 3.9.0
- rspec-mocks 3.9.1
- rspec-rails 3.9.0
- rspec-support 3.9.2
回答1件
あなたの回答
tips
プレビュー