Henley Wing Chiu
Henley Wing Chiu

Reputation: 22515

Running "rake test" in production environment?

I want to run unit tests in a Cron Job in a Production environment. Due to restrictions in the # of machines I have in my disposal, I can only run these units tests in 1 production machine. I don't have a development machine/environment. Let's imagine this is the case (even if it's not a realistic and a bad setup) and I can't change that at all :)

Is it possible to run "rake test" or even "rake test RAILS_ENV=test" in a production environment? And if I do, would it always run the tests on the test database, not on the production one? And it it does, would the environment be "test" only within the scope of the test?

Obviously, I could test this, but because I don't want to risk production data, I rather have a firm answer before doing this.

Upvotes: 3

Views: 1336

Answers (1)

jhuckabee
jhuckabee

Reputation: 66

Yes, this will work just fine. Make sure you specify the RAILS_ENV environment variable like you already have and that you have the test database configured in your database.yml file.

Upvotes: 3

Related Questions