基于 DataMapper 模板的 Rails 3 项目中缺少“test”rake 任务
如何取回测试任务?
背景故事:我没有从默认的新 Rails 项目开始。我将 datamapper 与 dm-rails 一起使用,并使用他们的 boodstrap 命令:
rails new project_name -m http://datamapper.org/templates/rails.rb
我的 Rakefile 如下:
require File.expand_path('../config/application', __FILE__)
require 'rake'
MyAppName::Application.load_tasks
How can I get the test tasks back?
Backstory: I didn't start with the default new rails project. I'm using datamapper with dm-rails and used their boodstrap command:
rails new project_name -m http://datamapper.org/templates/rails.rb
My Rakefile is as follows:
require File.expand_path('../config/application', __FILE__)
require 'rake'
MyAppName::Application.load_tasks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在默认的 Rails 3 项目中,
config/application.rb
包含require 'rails/all'
,基本上需要所有的 Rails 框架(ActiveRecord、ActiveResource、ActionController、ActionMailer、 TestUnit 等)DataMapper 模板改变了这一点。由于它不使用 ActiveRecord,因此它不能
require 'rails/all'
而不引起问题。它实际保留的唯一默认 Rails 组件是 ActionController。它为 ActiveResource、ActionMailer 和 TestUnit 放入require
语句,但默认情况下将它们注释掉。长话短说:在 config/application.rb 中取消注释以下行:
In a default Rails 3 project,
config/application.rb
containsrequire 'rails/all'
, basically requiring all of the rails frameworks (ActiveRecord, ActiveResource, ActionController, ActionMailer, TestUnit, etc.)The DataMapper template changes this. Since it doesn't use ActiveRecord, it can't
require 'rails/all'
without causing problems. The only default Rails component it actually keeps is ActionController. It puts inrequire
statements for ActiveResource, ActionMailer, and TestUnit, but comments them out by default.Long story short: uncomment the following line in
config/application.rb
: