LoginSignup
1
0

More than 3 years have passed since last update.

Failure/Error: require File.expand_path('/../config/environment', __dir__) というエラー

Posted at

エラー文

結合テストコードの1行目のrequireが読み込まれていないらしい...

An error occurred while loading ./spec/system/users_spec.rb. - Did you mean?
                    rspec ./spec/system/comments_spec.rb

Failure/Error: require File.expand_path('/../config/environment', __dir__)

LoadError:
  cannot load such file -- /config/environment
# ./spec/rails_helper.rb:4:in `require'
# ./spec/rails_helper.rb:4:in `<top (required)>'
# ./spec/system/users_spec.rb:1:in `require'
# ./spec/system/users_spec.rb:1:in `<top (required)>'
No examples found.

('/../config/environment', __dir__)

('../config/environment', __dir__)

原因

('../../config/environment', dir)というふうに記述すれば直るという記事を見て変更してみたがうまくいかなく戻し他たきに戻し間違えたと考えられる。
根本的にはcapybaraなどのテスト用gemをgemfileのテストの部分のみに記述していたのが原因だったようだ。それをtestとdevelopmentに適用される部分に記述し直し、bundle installをすると直った。

1
0
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
1
0