How do I run an rspec test under different conditions?

I am running my rspec tests in a test environment. But I have one test that needs to use the development database. (I am running curl command with RestClient, which creates an object in the database (Photo table)). I need to check this object in a normal database.

In my spec_helper, I have ENV ["RAILS_ENV"] || = 'test'

I tried adding ENV ["RAILS_ENV"] = 'development' in this single test, but it still says Uninitialized constant Photo.

Any idea?


source to share

2 answers

Try adding RAILS_ENV = development in the console before your test team.

Uninitialized constants mean that something hasn't been configured yet. Maybe the model or controller is trying to access the "photo"?



Although this is not the answer.

This is totally wrong. You don't have to access the development environment for any of your tests. By setting the required data in a test environment, your tests will work.



All Articles