class Fixturama::Changes::Env
@private Stub an environment variable
Attributes
options[R]
Public Class Methods
new(**options)
click to toggle source
# File lib/fixturama/changes/env.rb 31 def initialize(**options) 32 @options = { options[:env].to_s => options[:value].to_s } 33 end
Public Instance Methods
call(example)
click to toggle source
# File lib/fixturama/changes/env.rb 19 def call(example) 20 original = Hash ENV 21 example.send(:stub_const, "ENV", original.merge(options)) 22 self 23 end
key()
click to toggle source
All changes has the same key
They will be merged before stubbing (see call
)
# File lib/fixturama/changes/env.rb 9 def key 10 "ENV" 11 end
merge(other)
click to toggle source
When we merge 2 env-s, we just merge their options
# File lib/fixturama/changes/env.rb 14 def merge(other) 15 return self unless other.is_a?(self.class) 16 dup.tap { |env| env.options.update(other.options) } 17 end