Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Missing Spec Files for RSpec

Is there any command available for generating all missing spec files for existing models / controllers? I have a project that has several models that have been generated with out spec files.

like image 245
Codebeef Avatar asked May 19 '09 09:05

Codebeef


3 Answers

In rspec-rails-2 which is intended for Rails 3 all of the rspec generators have been removed.

You can solve this problem by running the rails model generator. You can add -s to skip any existing files and --migration=false to skip creating the migration file.

Like so:

rails generate model example -s --migration=false
like image 193
Benry Avatar answered Oct 26 '22 10:10

Benry


You could just run the generator and ignore the models/migrations/fixtures.

ruby script/generate rspec_model User --skip-migration --skip-fixture --skip

I've been looking into writing something to do this but there hasn't been any interest from others.

like image 41
Brian Hogan Avatar answered Oct 26 '22 10:10

Brian Hogan


If the number of missing specs is rather small, you could simply run the rails generate commands for each components with missing specs.

When a conflict arises, simply opt not to overwrite the original file. The generator will ignore the existing files and generate the missing ones.

like image 38
Sung Cho Avatar answered Oct 26 '22 09:10

Sung Cho