Class: Fixturama::Changes::Env

Inherits:
Base
  • Object
show all
Defined in:
lib/fixturama/changes/env.rb

Overview

Stub an environment variable

Instance Attribute Summary

Attributes inherited from Base

#key The key identifier of the change

Instance Method Summary collapse

Instance Method Details

#call(example) ⇒ Object



19
20
21
22
23
# File 'lib/fixturama/changes/env.rb', line 19

def call(example)
  original = Hash ENV
  example.send(:stub_const, "ENV", original.merge(options))
  self
end

#keyObject

All changes has the same key They will be merged before stubbing (see call)



9
10
11
# File 'lib/fixturama/changes/env.rb', line 9

def key
  "ENV"
end

#merge(other) ⇒ Object

When we merge 2 env-s, we just merge their options



14
15
16
17
# File 'lib/fixturama/changes/env.rb', line 14

def merge(other)
  return self unless other.is_a?(self.class)
  dup.tap { |env| env.options.update(other.options) }
end