I introduced RSpec in an application, and when I ran the test code, I got an error. Why shouldn’t it work even though I think there should be no problem with the settings and descriptions no matter how many times I review it? ..
**The cause was a gem called “spring”. ** Typing the following command in the app directory and running the test code again worked fine. Was good.
[email protected] myApp %spring stop Spring stopped. ← OK if this notation appears
By the way, please be assured that this spring will automatically restart when you enter the rails command.
Who is this spring?
Simply put, it’s like a rails cache. It is introduced by default in Gemfile when you rails new.
In this case, the cache before the introduction of RSpec happens to remain, When I run the test code in that state, it seems that an error “RSpec cannot be used” has appeared.
By the way, to check the state 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 input in the order of
spring stop →
rails c →
spring status, it becomes 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 188.8.131.52) 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 on the 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 tried to execute it, but I couldn’t stop it by recovering immediately.
After all, it seems better to move to the corresponding directory and do a
spring stop obediently.