title: How to set different environment variables for test and development when using Foreman
body: <p>Currently I store sensitive information (e.g. API keys) in a <code>.env</code> file that is loaded by the Foreman gem. This works well and I am able to access environment variables that are the same in both development and test.</p>
  
  <p>I'd like to be able to use a different set of API keys for my test environment than my development environment.</p>
  
  <p>I tried doing something like <code>.env.development</code> and <code>.env.test</code> based on what I'd seen <a href="https://www.rubydoc.info/gems/dotenv/2.7.5" rel="nofollow noreferrer">https://www.rubydoc.info/gems/dotenv/2.7.5</a></p>
  
  <p>In case it's useful here is the general stack that I'm working with: Rails 5.2.3, Minitest, Guard (to run my tests on save), and Foreman. Currently this app is being deployed to Heroku.</p>
  
  <p>Here's my <code>test_helper.rb</code>:</p>
  
  <pre class="lang-rb prettyprint-override"><code>ENV['RAILS_ENV'] ||= 'test'
  require_relative '../config/environment'
  require 'rails/test_help'
  require 'vcr'
  
  VCR.configure do |config|
    config.cassette_library_dir = "test/cassettes"
    config.hook_into :faraday
  end
  
  class ActiveSupport::TestCase
    # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
    fixtures :all
  
    # Add more helper methods to be used by all tests here...
  end
  
  </code></pre>
  
  <p>My current work around is to have an additional environment variable with a suffix of <code>_test</code> that I use to override the ENV with in the <code>test_helper.rb</code>. That doesn't feel right to me though.</p>