Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

ruby on rails - 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:

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:

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Rails 4.1+, they deprecated db:test:prepare with that message. You can now just use:

ActiveRecord::Migration.maintain_test_schema!

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...