bkeepers / dotenv

A Ruby gem to load environment variables from `.env`.
MIT License
6.61k stars 505 forks source link

Autorestore ENV between tests #472

Closed bkeepers closed 10 months ago

bkeepers commented 10 months ago

This adds Dotenv.save and Dotenv.restore to save and restore the ENV, and automatially configures Rails apps to use it in tests (RSpec or AS::TestCase).

Disable by setting config.dotenv.autorestore = false in config/enviroments/test.rb or config/application.rb

Prior art:

Even though those are fine alternatives, I think it's still worth including this in dotenv by default.