rails: 执行rake test而不清除测试数据库中的数据
来源:互联网 发布:剑三捏脸数据成男鹿晗 编辑:程序博客网 时间:2024/06/04 23:25
以下技术应用于最优质的水果的鲜果篮
执行rake test,rails默认会做:
1, Remove any existing data from the table corresponding to the fixture
2, Load the fixture data into the table
3, Dump the fixture data into a variable in case you want to access it directly
为了避免清除测试数据库中的数据,需要:
1, 在lib/tasks文件夹下面创建新文件,以.rake为扩展名(例如,keep_data.rake),并加入以下代码。
Rake::TaskManager.class_eval dodef delete_task(task_name)
@tasks.delete(task_name.to_s)
end
Rake.application.delete_task("db:test:purge")
Rake.application.delete_task("db:test:prepare")
end
namespace :db do
namespace :test do
task :purge do
end
task :prepare do
end
end
end
2, 在test/test_helper.rb中注释掉这行代码:fixtures :all
- rails: 执行rake test而不清除测试数据库中的数据
- Ruby on Rails中的Rake教程(Rake如何把我灌醉!)
- 用rails中rake管理mysql数据库
- Ruby on Rails中的Rake教程
- 如何将Gem中的rake任务导入Rails Project中
- Rails Rake指南
- Rails Rake 指南
- Rails Rake指南
- rails rake db
- 清除数据库中表中的所有数据
- SOAPUI读取Excel数据执行循环测试(loop test)
- 解决rails 执行 rake db:migrate时Error in my_thread_global_end(): 1 threads didn't exit错误
- ruby on rails执行RAILS_ENV=production rake assets:precompile报warning
- rails rake脚本快速入门
- rails学习笔记: rake db
- rails中创建rake任务
- rails之自定义Rake任务
- 不为测试而测试
- 遍历文件,并执行相应操作
- hdu 1272 小希的迷宫
- 一些开源项目网址
- 带参数,给文件夹赋予对应权限
- 【精心推荐】20款优秀 jQuery Accordion(手风琴)特效插件
- rails: 执行rake test而不清除测试数据库中的数据
- CAS协议介绍和在apache使用cas实现单点登录sso
- vs MD MT等运行时库区别
- 跨数据库批量导入数据
- php入门第六天
- 批量改名
- 类加载器及其委托机制的深入分析
- hdu 4089 Activation 概率DP
- jq 、xml 省市级联动