DatabaseCleaner 清理测试和开发?

DatabaseCleaner cleans test and development?

为什么此配置似乎同时清理了我的 testdevelopment 数据库?每次我 运行 rspec.

都必须重新播种 development 很烦人
config.before(:suite) do
  DatabaseCleaner.strategy = :transaction
  DatabaseCleaner.clean_with(:truncation)
end

database.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:

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

ENV['RAILS_ENV'] ||= 'test'