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

Zach Dennis zach.dennis at gmail.com
Thu Jan 10 17:10:42 EST 2008

We have been following a similar directory structure on the current
project I am on. We started only using names like "edit_spec.rb" for
controller specs, but it soon became painful for our editor of choice,
TextMate, when trying to quickly find the edit spec for a particular

I think the directory organization is a good thing and it makes for
more meaningful specs IMO even though I don't use scaffold generated
code or specs,


On Jan 10, 2008 3:23 PM, Evan Short <evan.short at gmail.com> wrote:
> 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:
> specs/
> |_ 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
> share.
> -evan
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel

Zach Dennis

More information about the rspec-devel mailing list