Igor Loskutov
Igor Loskutov

Reputation: 2354

Rspec keeps using development database

I have different databases for development and for test in database.yml.

I have ENV['RAILS_ENV'] = 'test' in start of both files rails_helper.rb and spec_helper.rb, generated with rspec initialisation command.

Also, I tried Rails.env = 'test' without success.

I run rspec as RAILS_ENV=test rake spec

I don't have ENV['RAILS_ENV'] setting or Rails.env setting anywhere in initialisation scripts.

However, Rspec keeps using development database instead of testing one.

I have checked a lot of similar questions around the internet and no answer helped.

Any solutions?

Upvotes: 1

Views: 557

Answers (1)

Frank
Frank

Reputation: 116

What version of rails are you using? Try rake db:test:prepare. In Rails 4+, It's deprecated but still works. It seems like in rails 4.1+, migrations are automatically checked for, and running db:schema:load will do the trick.

Upvotes: 2

Related Questions