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:
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 :
group :development, :test do gem 'rspec-rails' end
- The development mode RSpec files add RSpec-specific generators
- Test mode includes files to run the tests
bundle install, Run this snippet to configure Rails to use RSpec in place of Test::Unit
rails generate rspec:installThis single command would generate you 4 new files :
We’ll cover more in detail regarding those later.
.rspec spec spec/spec_helper.rb spec/rails_helper.rb`
Updating the test databaseCheck for pending migrations and load the test schema
rake db:test:prepareN.B Preparing your test database
Run your test suit
rspecYup, Its simple as that… :)]]>