[RUBY] [Rails / Maybe it can be applied to other things? ] What to do if failure / error __send__ (method file) rspec cannnot road such file appears when executing RSpec

Introduction

Hello, My name is yuki. Thank you. Currently, I am working as a web engineer at a logistics company. (1st year) Our main language is PHP, but I sometimes use Ruby for personal development. This time I wrote an article about RSpec.

Target of readers

--Those who have an error in the subject --Those who have encountered an error and the word "load" is included in the error statement

What you can read and understand

--How to solve the error in the subject --A kind of approach to Load-related errors

The situation where the error occurred

When I was a programming mentor, the students Rspec execution command When I did bundle exec rspec spec --format documentation, I got an error in the subject.

Cause

The direct cause was ** creating two spec folders **. It seems that there was an error when loading due to that.

When I try to decipher the error statement, at first glance it seems that the file does not exist because it is rspec cannnot road such file, but in fact it was caused by something extra.

I was a little worried about how "Load" related errors are caused by this, so I investigated it.

Survey results

I have confirmed that the same error occurs in the following situations.

--The file name (folder name) is not spec, but a type such as sepc is used. --The file you are trying to reference does not exist in the first place

Summary

Not limited to this time, when loading any file ...

#Are there any typing mistakes?
#Does it exist in the specified location?
#Does the specified file exist more than once?

I thought I should be careful if I did the above. It may be applicable to other things as well, so I hope you find it helpful.

Introduction of our company

I am currently working for a logistics x technology company called Dialog Co., Ltd.. As of September 2020, we are not recruiting engineers, but we are looking for various other occupations, so please visit the Wantedly page. Please look. I would be happy if someday someone would apply for my Qiita opportunity.

Interview article (impressions after joining the company)

Recommended Posts

[Rails / Maybe it can be applied to other things? ] What to do if failure / error __send__ (method file) rspec cannnot road such file appears when executing RSpec
[Ruby] What to do when the error "cannot load such file" appears when executing VS Code debug
What to do if Failure / Error: require File.expand_path ('../ config / environment', __dir__) appears in RSpec
[Ruby / Rails] What to do when NoMethodError appears when using a destructive method such as filter!
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied
What to do if rails server can't be stopped
What to do when rails creates a 〇〇 2.rb file
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
[Rails] What to do if you can't get an error message with the errors method
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina