Sha256: bc0741651248fb96d0b48ae4ae1831fba9dc219b5d57d6c6e86495248028c751
Contents?: true
Size: 824 Bytes
Versions: 1
Compression:
Stored size: 824 Bytes
Contents
require "env_test_helpers/version" module EnvTestHelpers # it 'does something with the FOO environment variable' do # with_env_vars 'FOO' => 'bar' do # # logic that depends upon ENV['FOO'] goes here # end # end def with_env_vars(vars) original = ENV.to_hash vars.each { |k, v| ENV[k] = v } begin yield ensure ENV.replace(original) end end # describe Thing do # before(:all) do # mock_env_vars('FOO' => 'bar') # end # it 'does something with the FOO environment variable' do # # logic that depends upon ENV['FOO'] goes here # end # end def mock_env_vars(vars) vars.each do |k, v| allow(ENV).to receive(:[]).with(k).and_return(v) end end end if defined? Rspec RSpec.configure do |c| c.include EnvHelpers end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
env_test_helpers-0.0.1 | lib/env_test_helpers.rb |