我正在使用Rails 4.0.0.rc1和sqlite3并尝试设置测试数据库进行测试. bundle exec rake db:test:prepare没有在测试数据库中创建表.在遵循
this question之后,我设法通过运行bundle exec rake db来设置测试数据库:schema:load RAILS_ENV = test -t任务包exec rake db的原因是什么:test:准备不设置数据库.
以下是2个rake任务的输出.
indika@indika-F3E:~/Documents/my_app$bundle exec rake db:test:prepare -t
** Invoke db:test:prepare (first_time)
** Execute db:test:prepare
indika@indika-F3E:~/Documents/my_app$
indika@indika-F3E:~/Documents/my_app$bundle exec rake db:schema:load RAILS_ENV=test -t
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:load
-- create_table("questions", {:force=>true})
-> 0.2590s
-- initialize_schema_migrations_table()
-> 0.0025s
-- assume_migrated_upto_version(20130518181153, ["/home/indika/Documents/my_app/db/migrate"])
-> 0.0007s
indika@indika-F3E:~/Documents/my_app$
database.yaml中的数据库配置是这样的.
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test: &test
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
cucumber:
<<: *test
请注意我的问题已经解决了.但我很想知道出了什么问题.
最佳答案 rake db:migrate RAILS_ENV = test适用于Ruby 2.0.0和Rails 4.0.0.rc1
rake db:test:由于某种原因准备不适用于新版本.