DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Remove Prereqs In Rake (Rails 1.1 And Rake 0.7)

03.12.2006
| 3625 views |
  • submit to reddit
        This code will remove the prequisitive to prepare the test database in Rails. Put it in your Rakefile.

module Rake
 class Task
   def remove_prerequisite(task_name)
     name = task_name.to_s
     @prerequisites.delete(name)
   end
 end
end

Rake::Task['test:units'].remove_prerequisite('db:test:prepare')
Rake::Task['test:functionals'].remove_prerequisite('db:test:prepare')
    

Comments

Snippets Manager replied on Thu, 2006/03/09 - 3:28pm

This works as advertised (tested in Rails 1.1.2 and Rake 0.7.1) only when I add change test/test_helper like this :
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")

require 'application'
require 'test/unit'
require 'action_controller/test_process'
require 'breakpoint'
(from the DatabaseLessApplication recipe in the RailsRecipes book. That recipe works only in Rails 1.0, not in 1.1)