运行 "db:test:load =>数据库:测试:清除"无需重置数据库 [英] run "db:test:load => db:test:purge" without resetting database
本文介绍了运行 "db:test:load =>数据库:测试:清除"无需重置数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行rake test:integration"时,它正在调用db:test:load => db:test:purge".我不想重新创建数据库,只想在不接触数据库的情况下运行测试用例.有什么办法吗?
When I am running "rake test:integration" it is calling "db:test:load => db:test:purge". I dont want to recreate database, just want to run test cases without touching database. Is the any way to do it ?
推荐答案
和我的评论一样
对于您的情况,它将类似于:-
For your case It will be something like:-
在您的 Rakefile 中:
In your Rakefile:
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end
在 lib/tasks/db/test.rake 中:
In 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
这篇关于运行 "db:test:load =>数据库:测试:清除"无需重置数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文