ruby-on-rails – 如何防止Rake测试调用任务db:test:prepare
发布时间:2020-12-16 21:37:14 所属栏目:百科 来源:网络整理
导读:每次我想运行Rake测试任务db:test:prepare正在被调用,并且它从schema.rb和迁移重建我的测试环境数据库.我想要的是禁用db:test的调用:准备当我想测试make Rails应用程序.是否可以不修改Rails宝石? 解决方法 以下是我看到的解决方案: 在你的Rakefile中:
每次我想运行Rake测试任务db:test:prepare正在被调用,并且它从schema.rb和迁移重建我的测试环境数据库.我想要的是禁用db:test的调用:准备当我想测试make Rails应用程序.是否可以不修改Rails宝石?
解决方法
以下是我看到的解决方案:
在你的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:prepare' namespace :db do namespace :test do task :prepare do |t| # rewrite the task to not do anything you don't want end end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |