May 24, 2010

Rails: Starting RSpec

This is basically the same deal as the Restful Authentication post below. I've used RSpec in the past (these quick start-up guides are not for beginners), I just need somewhere to quickly reference the beginning commands/code snippets to start my Rails applications.

Here it goes!

Installing RSpec and RSpec for Rails

sudo gem install rspec
sudo gem install rspec-rails

Generate RSpec subdirectory for tests

script/generate rspec

Use RSpec scaffolding tool instead of regular scaffold! This way, you get the basic tests for each new controller/model/view you are creating.

script/generate rspec_scaffold model_name ...

If you're looking to learn RSpec, The RSpec Book is an excellent reference.