[rspec-users] is there a way to create spec tests (including directories) for an existing set of models/controllers?>>

Ben Mabey ben at benmabey.com
Fri Sep 5 02:18:24 EDT 2008


Greg Hauptmann wrote:
> Hi,
>
> is there a way to create spec tests (including directories) for an
> existing set of models/controllers?   (i.e. as opposed to the generate
> options that rspec provides when you are creating models/controllers
> etc to start with)
>
> Tks
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>   

The two quick and easy ways I can think of are:

a) Run the ./script/generate/rspec... commands for each model and
controller.  When prompted to overwrite the existing model/controller
just say no (the specs will still be created.)
b) If your using TextMate on OSx with the rspec bundle you can use the
"switch command" (Ctl-Shift Down) while on the model/controller and it
will prompt you if you want to create a matching spec for that file.

The maybe quicker but harder way I can think of is to create your own
simple generator/script that iterates over the existing files and
creates spec files for them if needed.

HTH,
Ben


More information about the rspec-users mailing list