Module: RSpec::StubbedEnv::StubHelpers — Documentation by YARD 0.9.37

# Module: RSpec::StubbedEnv::StubHelpers

Included in:
  HideHelpers

Defined in:
  lib/rspec/stubbed_env/stub_helpers.rb

## Overview

Helpers to unobtrusively stub ENV

## Instance Method Summary collapse

- #stub_env(key_or_hash, value = nil) ⇒ Object

  Can be called with all key value pairs to be stubbed as a hash:.

## Instance Method Details

### #stub_env(key_or_hash, value = nil) ⇒ `Object`

Can be called with all key value pairs to be stubbed as a hash:

    stub_env('A' => 'B', 'C' => 'D', 'E' => 'F') # Preferred

Alternatively can be called one per ENV key-value pair to stub:

    stub_env('A', 'B') # NOT
    stub_env('C', 'D') # AS
    stub_env('E', 'F') # GOOD (Creates redundant stubs on values_at)

    40
    41
    42
    43
    44
    45
    46
    47
    # File 'lib/rspec/stubbed_env/stub_helpers.rb', line 40

    def stub_env(key_or_hash, value = nil)
      init_stub unless env_stubbed?
      if key_or_hash.is_a?(Hash)
        key_or_hash.each { |k, v| add_stubbed_value(k, v) }
      else
        add_stubbed_value(key_or_hash, value)
      end
    end