Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate all RSpec spec files from existing controllers, models & views in a Rails app

Does anyone know of a rake task or RSpec call that will generate a bunch of empty files relative to the existing controllers, models, helper files and views that already exist within your application?

like image 720
matsko Avatar asked Jan 11 '12 15:01

matsko


1 Answers

You can generate an empty scaffold set of rspec tests against an existing controller using something like this:

rails generate rspec:scaffold recipe

You can improve on this by passing the attributes of the model you want to generate against, like this:

rails generate rspec:scaffold recipe title: string slug: string description: text

You'll still need to do some manual editing, but this should get you most of the way there.

like image 124
superluminary Avatar answered Nov 10 '22 08:11

superluminary