Skip to content

Instantly share code, notes, and snippets.

@joho
Created February 16, 2009 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joho/65471 to your computer and use it in GitHub Desktop.
Save joho/65471 to your computer and use it in GitHub Desktop.
Quickly add empty specs for all your models
desc "create missing rspecs for all models"
task :create_missing_model_specs do
models = Dir.open("#{RAILS_ROOT}/app/models").collect {|file_name| file_name.split('.')[0] }
models.each do |model|
if model && model.size > 0
spec_path = "#{RAILS_ROOT}/spec/models/#{model}_spec.rb"
unless FileTest::exist?(spec_path)
puts "creating missing #{model} spec"
File.open(spec_path, "w") do |f|
f.puts "require File.dirname(__FILE__) + '/../spec_helper'"
f.puts "module #{model.camelize}Methods"
f.puts "end"
f.puts
f.puts "describe #{model.camelize} do"
f.puts "\tit \"should have boat-loads of coverage\""
f.puts "end"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment