-
-
Notifications
You must be signed in to change notification settings - Fork 285
Description
Using a Rails app as an example, a developer may want to load certain default values when Rails.env.development? and others when running the test suite and Rails.env.test?. Both of these cases should use the same Envfile. So what's the most intuitive way to load different default values based on the environment, keeping in mind that Figaro 2.0 is dropping the explicit Rails dependency?
Some initial thoughts:
# Envfile
defaults ".env.yml", key: -> { Rails.env }
string :foo# .env.yml
development:
foo: bar
test:
foo: baz# Envfile
defaults ".env.yml"
defaults ".env.test.yml", if: -> { Rails.env.test? }
string :foo# .env.yml
foo: bar# .env.test.yml
foo: bazI'd like to be explicit about what's being loaded and avoid hidden conventions. Think about Bundler and how you source "https://rubygems.org" at the top of every Gemfile. The Bundler team could have made that the default source since it is 95% of the time, but they opted for clarity.
I'd love to get others' thoughts on these two ideas and suggestions for more ideas. Thank you!