Rails3 RSpec is wiping wrong database?
I am trying to get my hands on Rspec2 with Rails3 (never used rspec before). I have rspec-rails 2.0.0.beta20. After introducing some basic tests into spec/models and running
rspec spec/models/user_spec.rb
everthing is fine. However if I just run
rake开发者_JS百科 spec
My development database is beeing wiped out. Even if I specify the environment explicitly
RAILS_ENV=test rake spec
My development database is beeing wiped to zero.
What I am doing wrong here? It feels like I am missing the concept for now. Anyone got any tips or could point me to some basic tutorial?
Set the following sentence at the top of your spec_helper.rb
file
ENV["RAILS_ENV"] ||= 'test'
This will ensure you use the right environment.
Stupid case. While moving the app from Rails2 to Rails3 I messed up database.yml, and my test db was set to devel. :)
精彩评论