开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜