Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Rails generators which produce tests using shoulda instead of straight up Test::Unit. Other goodies as well.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 rails_generators
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO
Octocat-spinner-32 VERSION.yml
Octocat-spinner-32 shoulda_generator.gemspec

Shoulda generators

One night at a Boston Ruby hackfest, I finally got sick of using the Rails default generators, and then having to twiddle them to meet my needs and tastes. This includes using things like:

The next morning, I was struck awake at 5am with the inspiration to start implementing it. shoulda_generator is the result of this effort.

What you get


  • A new model
  • A migration for the model
    • Skip using --skip-migration
  • A factory defined with factory_girl
    • Skip using --skip-factory
  • A shoulda unit test with a few simple 'should's



  • Everything included in shoulda_model
  • A controller (sans unnecessary comments)
  • Choice of haml (default) or ERB
    • Specify which with the --templating option
  • Simple layout styled with blueprint
    • Skip using --skip-layout
  • A helper
  • A shoulda functional test using factory_girl factory, using should_be_restful or not
    • Specify with --functional-test-style, accepts basic and should_be_restful


Getting it

shoulda_generator is available as a gem via GitHub. If you haven't done so already, you need to setup GitHub as a gem source:

$ gem sources -a

Now you can install it:

$ sudo gem install technicalpickles-shoulda_generator

Example usage

Usage is the same as the default Rails generators.

$ script/generate shoulda_model post title:string body:text published:boolean 
$ script/generate shoulda_scaffold post title:string body:text published:boolean

Configuring it

You can override the default values for templating and functional_test_style by placing a .shoulda_generator file in your home directory.

Here's an example .shoulda_generator:

:templating: erb              # supported options: haml|erb
:functional_test_syle: basic  # supported options: should_be_restful|basic

Developing it

Source is hosted on GitHub:

You can do the usual fork/commit cycle until you have something ready to share. Send pull requests my way.

Something went wrong with that request. Please try again.