Rails: Make request to development environment while using tests

时间:2015-06-25 18:16:20

标签: ruby-on-rails database testing module

I would like to know how I could make a request on my development environment from the tests environment.

I know it's not a good practice but I don't know how to achieve my goal otherwise: On my project, I've created some modules (Newsletter, Search, GuestBook, ...) and I would like to have a table allowing me to enabled or disabled modules. I have created the scaffold for this.

The but of all of this is to not run tests if the setting is disabled in other environments.

My problem is when I make a request to check if the module is enabled or not, it targets the test database and not the development database.

Anyone know how I could solve my problem ? Thanks for your help

1 个答案:

答案 0 :(得分:0)

You don't want to do it that way, you want to set the same DB in your test environment so that it will check that table in your test DB during the testing.

...or even better, stub out the model used to retrieve those enabled/disabled settings so you can just adjust them on the fly as you run various tests.