First of all, we will need to setup Rspec on Rails 3,
sudo gem install rspec
sudo gem install rspec-rails --pre
Then we include them in our gemfile,
gem 'rspec'
gem 'rspec-rails'
Then we will run the generator:install,
rails g rspec:install
which will provide us with all the files/directory that we need to use Rspec
For a more robust TDD/BDD, we could install autotest. This would assure that each time we edit the test file, the Rspec test will be conducted automatically without the need of us typing the command out.
gem install autotest
gem install autotest-fsevent
gem install autotest-growl (For some reason i still couldn't set it up to work with Growl for OSX)
Open the autotest file,
mate ~/.autotest
Add these 2 lines to the file
require "autotest/fsevent"
require "autotest/growl"
Kick it off with
autotest
If we are testing model, be sure to do
rake db:test:prepare
or Rspec will complain.
More information and documentation can be found at:-
0 comments:
Post a Comment