当我运行“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
关于ruby-on-rails - 运行 "db:test:load => db:test:purge"而不重置数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18698117/