2011-08-30 46 views
3

在我的功能/支持/ env.rb文件的頂部:我的黃瓜測試正在修改開發數據庫。我如何獲得它來修改測試分貝?

ENV["RAILS_ENV"] = 'test' 

但測試仍在修改發展分貝.... 即使當我做

rake cucumber:authentication RAILS_ENV=test 

它仍然改變dev db

我還需要改變什麼?

的database.yml:使用

development: 
    adapter: mysql 
    encoding: utf8 
    database: app_dev 
    username: root 
    password: 

test: 
    adapter: mysql 
    encoding: utf8 
    database: app_test 
    username: root 
    password: 

production: 
    adapter: mysql 
    encoding: utf8 
    database: app_production 
    username: root 
    password: 

cucumber: &CUCUMBER 
    adapter: mysql 
    encoding: utf8 
    database: app_cuke 
    username: root 
    password: 

culerity: 
    <<: *CUCUMBER 

ruby 1.8.7 
    rails 2.3.8 
    and cucumber 1.0.2 

回答

0

檢查database.yml的 也許你已經指定開發數據庫測試ENV?

好了,基本的安裝步驟是

bundle install 
rails generate cucumber:install 

檢查database.yml中,指定正確的連接細節

rake db:create 
rake db:migrate 

檢查黃瓜

rake cucumber 

什麼是這個步驟的結果? 特別是你創建並遷移數據庫的測試?

+2

我會更新我的問題,證明我不是TAHT retarded = p – NullVoxPopuli

0

我也有類似的問題,我解決了它這樣的:

cucumber.rake我添加rake任務

task :ensure_test_env do 
    ENV['RAILS_ENV'] = 'test' 
end 

,然後我做了所有黃瓜任務取決於它像

Cucumber::Rake::Task.new({:ok => ['db:test:prepare', :ensure_test_env]}, ... 
0

另外dotenv可能會導致這種情況,因爲如果在.env文件中設置了DATABASE_URL,則無論如何都將使用此數據庫。這導致我的測試連接到我的開發數據庫。