Greg Hauptmann
2008-Sep-05 05:57 UTC
[rspec-users] is there a way to create spec tests (including directories) for an existing set of models/controllers?>>
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
Ben Mabey
2008-Sep-05 06:18 UTC
[rspec-users] is there a way to create spec tests (including directories) for an existing set of models/controllers?>>
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
Scott Taylor
2008-Sep-05 06:28 UTC
[rspec-users] is there a way to create spec tests (including directories) for an existing set of models/controllers?>>
On Sep 5, 2008, at 1:57 AM, 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)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
Greg Hauptmann
2008-Sep-05 13:49 UTC
[rspec-users] is there a way to create spec tests (including directories) for an existing set of models/controllers?>>
thanks Ben - this works nicely On Fri, Sep 5, 2008 at 4:18 PM, Ben Mabey <ben at benmabey.com> wrote:> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >