Tests are great to have for any Rails application, but it can become inconvenient to have to run them repeatedly. Two utilities, Guard and Spork, can be used in conjunction to help streamline your test suite and speed up your tests.
Guard is a utility which helps automate your tests. You can specify which files you want it to watch, and Guard will run your test suite when changes are made to those files. But, even better, the whole test suite will not run – only the tests relating to the files that were changed. You can also make customizations so that additional tests will run when you need them to, and so that tests stop running once one fails so that the entire testing group does not have to run each time.
Spork has a different purpose. It serves to significantly speed up the time it takes to run all of your tests. One of the time-consuming factors of running rspec tests is that your application has to run, in its entirety, before the tests are run. However, Spork helps solve this. It is basically a test server that loads the application once, and then will hold that in memory for tests to be run quickly. It will incorporate changes as they’re made to the code, as well.
The real power of Guard and Spork comes when they’re used in conjunction. You can connect Guard and Spork so that Guard launches a Spork server and runs its automated tests on that.