Is there a way to create spec tests (including directories) for an existing set of models/controller

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

Greg H. wrote:

[email protected]
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

On Sep 5, 2008, at 1:57 AM, Greg H. 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)

No, I don’t think there is any code to do that, explicitly, but I’m
sure you could adapt it to do that:

Write a script to poll the directories for the files, run humanize on
it, call the generator for each one of those. It will prompt you to
overwrite the files. Say “no”.

Scott

thanks Ben - this works nicely

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs