This article describes the RSpec setup process in your Rails application.
When generating a new Rails project, just add the flag –skip-test-unit to supress creation of the test directory associated with the default Test::Unit framework as won’t be needing that.
In the Gemfile, add:
group :development, :test do
RSpec-Rails has a dependency to RSpec, so we don’t need to include it separately.
Yeah, we need it in development env too. Let’s see why :
- The development mode RSpec files add RSpec-specific generators
- Test mode includes files to run the tests
Once you have run bundle install, Run this snippet to configure Rails to use RSpec in place of Test::Unit rails generate rspec:install
This single command would generate you 4 new files :
We’ll cover more in detail regarding those later.
Updating the test database
Check for pending migrations and load the test schema rake db:test:prepare
Run your test suit
Yup, Its simple as that… 🙂