2013-05-19 19 views
4

我正在使用Rails 4.0.0.rc1與sqlite3並嘗試設置測試數據庫進行測試。 bundle exec rake db:test:prepare未在測試數據庫中創建表。在完成this question之後,我設法通過運行bundle exec rake db:schema:load RAILS_ENV=test -t來設置測試數據庫。什麼可能導致任務bundle exec rake db:test:prepare無法設置數據庫。rake db:test:prepare不會設置測試數據庫

以下是2個rake任務的輸出。

[email protected]:~/Documents/my_app$ bundle exec rake db:test:prepare -t 
** Invoke db:test:prepare (first_time) 
** Execute db:test:prepare 
[email protected]:~/Documents/my_app$ 

[email protected]:~/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 
[email protected]:~/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 

請注意,我的問題已解決。但我很想知道出了什麼問題。

回答

2

rake db:migrate RAILS_ENV=test適用於Ruby 2.0.0和Rails 4.0.0.rc1 rake db:test:由於某種原因準備不適用於新版本。

+0

謝謝...有誰知道爲什麼? –

+2

它在導軌4中被移除,現在自動維護。請參閱:[鏈接](https://github.com/rails/rails/pull/13528) –

相關問題