"RSpec doesn't work!" The cause was spring, so I investigated it.

I installed RSpec in an application, and when I ran the test code, I got an error. No matter how many times I review it, there should be no problem with the settings and description, but why doesn't it work? ..

** The cause was a gem called "spring". ** ** I entered the following command in the app directory and ran the test code again and it worked fine. Was good.

[email protected] myApp % spring stop
Spring stopped.← OK if this notation appears

By the way, don't worry, this spring will restart automatically when you enter the rails command.

Who is this spring?

Simply put, it's like a rails cache. It is installed by default in Gemfile when rails new.

In this case, the cache before the introduction of RSpec happens to remain, If you execute the test code in that state, it seems that you get an error saying "RSpec cannot be used".

By the way, to check the status of spring, you can check it like this.

[email protected] myApp % spring status
Spring is running:

97404 spring server | myApp | started 10 secs ago   
97405 spring app    | myApp | started 10 secs ago | development mode   

If you enter in the order of spring stop rails c → ʻexitspring status`, it will look like this.

[email protected] myApp % spring stop
Spring stopped. 

[email protected] myApp % rails c
Running via Spring preloader in process 97418
Loading development environment (Rails 6.0.3.2)
irb(main):001:0> exit

[email protected] myApp % spring status
Spring is running:

97404 spring server | myApp | started 10 secs ago   
97405 spring app    | myApp | started 10 secs ago | development mode

By the way, you can check all the springs running in your PC with the following command.
[email protected] ps aux | grep spring
mac        97139 101.0  0.5  4370124  43216   ??  Rs    2:24AM   0:00.73 spring app    | myApp3 | started 0 secs ago | development mode      
mac        97106   0.2  0.3  4352516  24104 s002  S     2:24AM   0:00.42 spring server | myApp3 | started 39 secs ago   
mac        96929   0.0  1.2  4462288 100216   ??  Ss    2:20AM   0:03.23 spring app    | myApp2 | started 4 mins ago | development mode      
mac        77394   0.0  0.1  4352516   8816   ??  S     05PM     0:01.03 spring server | myApp2 | started 56 hours ago   
mac         4764   0.0  0.0  4486444    472   ??  Ss    5 720    1:18.61 spring app    | myApp1 | started 439 hours ago | development mode      
mac         4760   0.0  0.0  4351492    432   ??  S     5 720    0:01.58 spring server | myApp1 | started 439 hours ago   
mac        97142   0.0  0.0  4276476    696 s002  S+    2:24AM   0:00.00 grep spring

I wondered if I could stop it with the kill command, but I couldn't stop it because it was restored immediately. After all it seems better to move to the corresponding directory and obediently spring stop.

Recommended Posts

"RSpec doesn't work!" The cause was spring, so I investigated it.
It doesn't work if the Map key is an array
parquet-tools gives java.lang.ExceptionInInitializerError, so I made it work with java8
I have a question because the gradle setup doesn't work
I investigated the enclosing instance.
The program doesn't work, the program doesn't stop ...
I don't understand the devise_parameter_sanitizer method, so I'll output it here.
[Spring Boot] I investigated how to implement post-processing of the received request.
The corretto I put in Homebrew disappeared after updating, so I fixed it.
I was in trouble at work, so I made a plugin for IntelliJ
It was a life I wanted to reset the thread-safe associative counter
A super beginner has completed the Spring introductory book, so I will summarize it in my own way