rdp edited this page Sep 12, 2010 · 18 revisions


rspec-rails extends RSpec and Ruby on Rails so you can specify the behaviour of your rails web-app.

Rails 3

Rails 3 requires rspec 2 . Development of rspec-rails-2 has moved to github.com/rspec/rspec-rails.

Rails 2.x

For rails, you’ll want to somehow have access to both “rspec” and “rspec-rails”

Here are various ways.

Use rspec and rspec-rails gems

See config.gem (for Rails)

Install rspec and rspec-rails plugins for Rails >= 2.1.0

ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.9'
ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.9'
ruby script/generate rspec

(change 1.2.9 to the latest gem released version)

Install rspec and rspec-rails plugins for Rails < 2.1.0

cd vendor/plugins
git clone git://github.com/dchelimsky/rspec.git
git clone git://github.com/dchelimsky/rspec-rails.git
cd rspec
git checkout 1.1.8
cd ../rspec-rails
git checkout 1.1.8
cd ..
rm -rf rspec/.git
rm -rf rspec-rails/.git
cd ../../
ruby script/generate rspec

File Layout Necessary

You can see a demo rspec layout by running ruby script/generate rspec_scaffold ModelName (creates model, specs).

It’s also listed here.