public
Rubygem
Description: Rails generators which produce tests using shoulda instead of straight up Test::Unit. Other goodies as well.
Clone URL: git://github.com/technicalpickles/shoulda_generator.git
name age message
file .gitignore Tue Jul 01 11:11:54 -0700 2008 Created Rakefile using echoe. Added manifest, .... [technicalpickles]
file LICENSE Fri Sep 05 11:41:46 -0700 2008 Added LICENSE. README cleanups. [technicalpickles]
file Manifest Wed Jul 02 15:49:06 -0700 2008 Supports should_be_restful now, with choice of ... [technicalpickles]
file README.markdown Fri Sep 05 11:41:46 -0700 2008 Added LICENSE. README cleanups. [technicalpickles]
file Rakefile Wed Oct 22 12:32:23 -0700 2008 Forgot default task. [technicalpickles]
file TODO Fri Sep 05 11:48:33 -0700 2008 Added TODO [technicalpickles]
file VERSION.yml Wed Oct 22 12:27:47 -0700 2008 Start using jeweler. [technicalpickles]
directory rails_generators/ Mon Oct 20 10:03:24 -0700 2008 Humanize some links/titles in templates. [technicalpickles]
file shoulda_generator.gemspec Wed Oct 22 12:27:47 -0700 2008 Start using jeweler. [technicalpickles]
directory test/ Thu Oct 16 21:52:01 -0700 2008 Working? [technicalpickles]
README.markdown

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

shoulda_model

  • 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

Prereqs:

shoulda_scaffold

  • 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

Prereqs:

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 http://gems.github.com

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: http://github.com/technicalpickles/shoulda_generator/tree/master

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