If like me, you deploy your Rails apps to Heroku, then one of the many benefits are environment variables, which are one of the requirements of developing a twelve-factor app. These are great for keeping your config out of source control.
You can also use local environment variables using the dotenv gem. These are stored at the root of your Rails app in a .env file, make sure you don’t commit this to source control and you’re all good. If you use the foreman gem, one of it’s dependencies is the dotenv gem so there is no need to add another line to your Gemfile.
When you add Rspec in to the mix though, it doesn’t automatically load these local environment variables by default.
This is easily resolved by editing spec/spec_helper.rb and adding the following to the top of the file.