简体   繁体   English

当我运行`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). 所以根据这个链接,一个是快捷包装器(所以我猜它们是相同的)。

When I ran bundle exec rake db:test:prepare , I get this error: 当我运行bundle exec rake db:test:prepare ,我收到此错误:

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>'

...but when I ran bundle exec rake db:test:prepare , I get this warning: ...但是当我运行bundle exec rake db:test:prepare ,我收到此警告:

WARNING: db:test:prepare is deprecated. The Rails test helper now maintains your test schema automatically, see the release notes for details.

Can anyone shed light on this? 任何人都可以阐明这一点吗?

In Rails 4.1+, they deprecated db:test:prepare with that message. 在Rails 4.1+中,他们弃用db:test:使用该消息进行准备。 You can now just use: 你现在可以使用:

ActiveRecord::Migration.maintain_test_schema!

in spec_helper.rb (or similar files if you're not using RSpec). 在spec_helper.rb(或类似的文件,如果你没有使用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. 由于这种“自动”方法,在大多数情况下不再需要db:test:prepare。

If you need to do it manually for some reason, you can still use 如果由于某种原因需要手动完成,您仍然可以使用

rake db:schema:load RAILS_ENV=test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM