2

为什么此配置似乎同时清理了我test和我的development数据库?development每次运行时都必须重新播种,这很烦人rspec

config.before(:suite) do
  DatabaseCleaner.strategy = :transaction
  DatabaseCleaner.clean_with(:truncation)
end

数据库.yml

development:
  adapter: postgresql
  database: m_development
  encoding: utf8
  pool: 5
  username: booltox
  password:

test:
  adapter: postgresql
  database: m_test
  encoding: utf8
  pool: 5
  username: booltox
  password:
4

1 回答 1

1

我很愚蠢,但这可能对其他人有所帮助。不要忘记在您的spec_helper.rb(感谢@dgilperez)中定义您的环境:

ENV['RAILS_ENV'] ||= 'test'
于 2015-05-22T06:20:09.627 回答