This is a great question!

I think ideally you should use different files for different environments:
.env/.env.test, for instance. Foreman can use a different env file with -e.

In practice I had some trouble applying that to a Rails 2.3 app, though. In
particular because of the test database manipulation, Rails really needed
both database urls - so we ended up with a single .env containing both
DATABASE_URL and TEST_DATABASE_URL.


On Wed, Feb 6, 2013 at 4:39 AM, vincent daubry <[email protected]> wrote:

> We manage a production and staging environment without any problem on
> Heroku, we followed these instructions :
>
> https://devcenter.heroku.com/articles/multiple-environments
>
> I dont think the problem you have with the test environnement is related
> to heroku ?
>
> Anyway, you probably don't want to hit RabbitMQ in your unit tests, to
> avoid that we use a facade class with Rails.env.test? in the ruby code. All
> the environment variables related to external services are filled with
> dummy values in the test.rb config file.
>
> For example we would have :
> RABITMQ_URL = "fake_url"
>
> If our test suite fails because of a failed connection to RabbitMQ it
> means one of our test is not properly stubbed (which is a good piece of
> information !)
>
> If anyone have a better solution, i would be happy to hear it.
>
> Hope this helps,
> Vincent
>
>
> Le mardi 5 février 2013 18:30:53 UTC+1, Keenan a écrit :
>
>>  Hi All,
>>
>> I have all my configuration values in environment variables.
>>
>> But this seems to break down for running tests.
>> We only have 1 .env file that we source from .rvmrc.
>> So the same environment variables are used for both development and test
>> (rails console and rake spec)
>>
>>
>> The solution for handling the 2 environments with one set of variables is
>> currently to hack ENV['DATABASE_NAME'] in spec_helper and use code like
>> this all over the place:
>> ENV['RABITMQ_URL'] + ENV['DATABASE_NAME']
>> Or to hardcore the test environment values in the yml files. and add
>> Rails.env.test? int he ruby code.
>>
>> As you'd imagine, this is starting to break down.
>>
>>
>> I assume the solution is to have 2 different environments, but I'm not
>> sure how to do this.
>> Where would I load in the second environment file so I don't by mistake
>> run rails console in the test environment or vice versa and blow away my
>> environment.
>>
>>
>>
>> How are other people handling the 2 different environments?
>>
>>
>> Thanks for any insight,
>> Keenan
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Heroku" group.
>
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en_US?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Heroku Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Heroku" group.

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/heroku?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"Heroku Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to