Set up rspec for rails app

26 Jul 2012

If you need to write tests with rspec for a rails app you need to use and setup "rspec-rails" gem. Rails is equipped with Test::Unit framework as it's default testing framework. We need to change the default test framework to rspec, so that we can use rails generator for generating tests.


You can start with skipping Test::Unit files while creating a new app.
Now add "rspec-rails" to the Gemfile.
Then bundle install
Now register the rspec as the testing framework replacing Test::Unit.
Hooray, you have done it. Now you can generate models, controllers and corresponding rspec test skeletons with the rails generator.
If you find my work helpful, You can buy me a coffee.