[rspec-devel] rest-friendly resource specs (rails generator)

Evan Short evan.short at gmail.com
Thu Jan 10 15:23:52 EST 2008

hello there. never posted to the list before, but i had a thought (which
turned into an action) and i thought i would share. this is in regards to
the rspec_resource generator packaged with rspec_on_rails.

it is not difficult for spec files to become very large very quickly. i
often find that as my specification files' size increase, so then does my
effort required to find what i am looking for, and on to an increased
reluctance to open them in the first place.

the solution that i have implemented, in terms of rails controllers, has
been to create a new generator: rest_scaffold. rest scaffold is a copy of
rspec_scaffold for everything except for the default controller specs. if
the rest_scaffold generator were run on MyResource, the spec folder would
appear as follows:

|_ models/
        |_ my_resource_spec.rb
|_ controllers/
        |_ my_resources_routing_spec.rb
        |_ my_resources/
                    |_ my_resources_create_spec.rb
                    |_ my_resources_update_spec.rb
                    |_ my_resources_delete_spec.rb
                    |_ my_resources_index_spec.rb
                    |_ my_resources_show_spec.rb
                    |_ my_resources_new_spec.rb
                    |_ my_resources_edit_spec.rb
 |_ views/
        |_ my_resources
                    |_ edit.html.erb_spec.rb
                    |_ index.html.erb_spec.rb
                    |_ new.html.erb_spec.rb
                    |_ show.html.erb_spec.rb

personally, i find this to be a wonderful aid. i find it much easier to find
my specifications, and much nicer to have the specified places to define
each of my actions. also, it plays nice with the rakefile.

you all, of course, may do with this as you please. just thought i would

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20080110/ba84b8ab/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rest_scaffold.tar.gz
Type: application/x-gzip
Size: 4327 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rspec-devel/attachments/20080110/ba84b8ab/attachment-0001.gz 

More information about the rspec-devel mailing list