Project

env_mock

0.0
No release in over 3 years
Low commit activity in last 3 years
Mock your ENVs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

EnvMock

CI Gem Version Maintainability codecov Sponsor

Mock your ENVs.

Install

Add the following code on your Gemfile and run bundle install:

gem 'env_mock'

Usage

ENV['DATABASE_USERNAME'] = 'root'

ENV['DATABASE_USERNAME']
=> 'root'

ENV['TAX_CENTS']
=> nil

ENV['UDP']
=> nil

EnvMock.mock(DATABASE_USERNAME: 'wbotelhos', TAX_CENTS: 700, 'udp' => true) do
  ENV['DATABASE_USERNAME'] # .to_s is called for all keys
  => 'wbotelhos'

  ENV['TAX_CENTS']
  => '700' # `.to_s` is called for all values

  ENV['UDP'] # .upcase is called for all keys
  => 'true'
end

ENV['DATABASE_USERNAME']
=> 'root'

ENV['TAX_CENTS']
=> nil

ENV['UDP']
=> nil