当我运行"rake test:integration"时,它调用"db:test:load => db:test:purge"。 我不想重新创建数据库,只想在不接触数据库的情况下运行测试用例。有什么办法可以做到吗?
它会和我的评论一样
对于您的情况,它将是这样的:-
在您的 Rakefile 中:
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end
在lib/tasks/db/test.rake中:
Rake.application.remove_task 'db:test:load'
Rake.application.remove_task 'db:test:purge'
namespace :db do
namespace :test do
task :load do |t|
# rewrite the task to not do anything you don't want
end
task :purge do |t|
# rewrite the task to not do anything you don't want
end
end
end