Reputation: 745
ENV variable values are set in config/application.yml in a rails app. is it possible to change only for specific test case in ActionDispatch::IntegrationTest? Something like this:
class DummyTest < ActionDispatch::IntegrationTest
context '...' do
it '...' do
ENV['API_URL'] = ...
end
end
end
I have tried this but it doesn't seem to change anything. Thanks
Upvotes: 0
Views: 200
Reputation: 1722
I think you've missed creating-rails-environments of the configuration on the Rails documentation. 😉
This should solve your issue without monkey patching anything on your specs.
I would also suggest to use dotenv gem which help you with environment variables. In your case you'll have at least those files:
If you really want to update a value for a specific test, I would suggest to stub it like suggested here
Upvotes: 1