Created
March 14, 2012 13:39
Revisions
-
spk created this gist
Mar 14, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ # encoding: utf-8 namespace :db do I18n.locale = :en desc "initialize" task :init => [:environment] do raise "\n Please run `rake db:seed` before" if User.all.blank? require 'ffaker' I18n.reload! require 'fabrication' Dir[Rails.root.join("spec/fabricators/**/*.rb")].each {|f| require f} # dont send email ActionMailer::Base.delivery_method = :test def generate_user Fabricate :user end def print_more print '.' STDOUT.flush end def nb (ENV['NB'] || 1).to_i end end desc "do all populate tasks" task :populate => [:init] do Rake::Task['db:populate:default'].invoke end namespace :populate do desc 'default: do all populate tasks' task :default => [ :user, ] desc "Create 10 users" task :user => :init do print "Create 10 users" (10 * nb).times { generate_user print_more } puts "" end end end