require 'spec/rake/spectask' desc 'Run all model and controller specs' task :spec do got_error = false %w(models controllers lib).each do |type| if File.exist?(File.join(File.dirname(__FILE__), '../../spec', type)) Rake::Task["spec:#{type}"].invoke rescue got_error = true end end # not yet supported #if File.exist?("spec/integration") # Rake::Task["spec:integration"].invoke rescue got_error = true #end raise "RSpec failures" if got_error end namespace :spec do %w(models controllers lib).each do |type| if File.exist?(File.join(File.dirname(__FILE__), '../../spec', type)) desc "Run the specs under spec/#{type}" Spec::Rake::SpecTask.new(type.to_sym => "db:test:prepare") do |t| t.spec_files = FileList["spec/#{type}/**/*_spec.rb"] end end end desc "Print Specdoc for all specs" Spec::Rake::SpecTask.new('doc') do |t| t.spec_files = FileList['spec/**/*_spec.rb'] t.spec_opts = ["--format", "specdoc"] end namespace :db do namespace :fixtures do desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y" task :load => :environment do require 'active_record/fixtures' ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*')) end end end end end