Why is RSpec so slow under Rails?

前端 未结 11 574
无人共我
无人共我 2020-12-24 05:00

Whenever I run rspec tests for my Rails application it takes forever and a day of overhead before it actually starts running tests. Why is rspec so slow? Is there a way to

11条回答
  •  别那么骄傲
    2020-12-24 05:41

    I think the "zen" experience you're looking for is to run spec_server and autospec in the background, with the result being near-instant tests when you save a file.

    However, I'm having problems getting these two programs to communicate.

    I found an explanation here:

    I've noticed that autotest doesn't send commands to the spec_server. Instead it reloads the entire Rails environment and your application's plugins everytime it executes. This causes autotest to run significantly slower than script server, because when you run the script/spec command the specs are sent to the spec_server which already has your Rails environment fired up and ready to go. If you happen to install a new plugin or something like that, then you'll have to restart the spec_server.

    But, how do we fix this issue? I'm guessing it would involve downloading ZenTest and changing code for the autotest program, but don't have time to try it out right now.

提交回复
热议问题