Before reading the article, you need to have a understanding of RSpec
My understanding of continuous testing is that, there is a testing tool in the background, which while developing and modifying code, it will continuously notify you the broken of correct code. I usually set up the testing environment using RSpec, Guard and Zeus. The setup process may easily go wrong. Thus I made a note of the process.
The tools we use
There are some tools we need to make testing super fast.
RSpec: famous testing framework, complies to BDD concept.
Guard: to guard the file change in Rails project.
Zeus: a tool to re-use the Rails environment in development environment, but also can be used in testing.
To achieve continuous testing, Guard will watch the changes in the project, and re-run the updated test cases or all the related.
Some of the gems I also use in testing:
factory_girl_rails: a mocking tool by Thoughtbot. One notice is that avoid using associates with it a lot
ffaker: an much faster alternative to Faker, which generates fake data, such as company name, content, etc..
Set up instructions
Starting from a fresh Rails 4 application, after creating the database(very important), add there gems to your Gemfile:
Then run these command in shell:
rails g rspec:isntall
guard init rspec
It will install RSpec and Guard.
Next, edit Guardfile a little bit. I will paste my Guardfile here:
Running the tests
Finally, let's test. Run guard to start the testing. Once the files being watched by guard updated, it will re-run the tests. Super fast.