当我运行 `bundle exec rake test:prepare` 时,它出错了,但是 `bundle exec rake db:test:prepare` 运行正常,但有警告.这是怎么回事? [英] When I ran `bundle exec rake test:prepare` it errored out, but `bundle exec rake db:test:prepare` goes through fine with warning. What's going on?
问题描述
所以根据 这个链接 一个是快捷包装器(所以我我猜他们是一样的).
So according to this link one is a shortcut wrapper (so I'm guessing they're the same).
当我运行 bundle exec rake db:test:prepare
时,我得到这个错误:
When I ran bundle exec rake db:test:prepare
, I get this error:
Don't know how to build task 'test:prepare'
/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
...但是当我运行 bundle exec rake db:test:prepare
时,我收到此警告:
...but when I ran bundle exec rake db:test:prepare
, I get this warning:
WARNING: db:test:prepare is deprecated. The Rails test helper now maintains your test schema automatically, see the release notes for details.
有人能解释一下吗?
推荐答案
在 Rails 4.1+ 中,他们弃用了带有该消息的 db:test:prepare.您现在可以使用:
In Rails 4.1+, they deprecated db:test:prepare with that message. You can now just use:
ActiveRecord::Migration.maintain_test_schema!
在 spec_helper.rb(或类似文件,如果您不使用 RSpec).这将自动使您的测试数据库与您的架构保持同步.由于这种自动"方法,在大多数情况下不再需要 db:test:prepare.
in spec_helper.rb (or similar files if you're not using RSpec). That will automatically keep your test database in sync with your schema. Because of this 'automatic' method, db:test:prepare is no longer needed in most cases.
如果由于某种原因需要手动操作,您仍然可以使用
If you need to do it manually for some reason, you can still use
rake db:schema:load RAILS_ENV=test
这篇关于当我运行 `bundle exec rake test:prepare` 时,它出错了,但是 `bundle exec rake db:test:prepare` 运行正常,但有警告.这是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!