Module: SpecInfra::Configuration

Defined in:
lib/specinfra/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :path,
  :pre_command,
  :stdout,
  :stderr,
  :sudo_path,
  :disable_sudo,
  :pass_prompt,
  :sudo_options,
  :docker_image,
  :lxc,
  :request_pty,
].freeze

Class Method Summary collapse

Class Method Details

.defaultsObject



18
19
20
# File 'lib/specinfra/configuration.rb', line 18

def defaults
  VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
end

.method_missing(meth, val = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/specinfra/configuration.rb', line 31

def method_missing(meth, val=nil)
  key = meth.to_s
  key.gsub!(/=$/, '')
  if val
    instance_variable_set("@#{key}", val)
    RSpec.configuration.send(:"#{key}=", val) if defined?(RSpec)
  end

  ret = instance_variable_get("@#{key}")
  if ret.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(key)
    ret = RSpec.configuration.send(key)
  end
  ret
end

.osObject

Define os method explicitly to avoid stack level too deep caused by Helpet::DetectOS#os



24
25
26
27
28
29
# File 'lib/specinfra/configuration.rb', line 24

def os
  if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
    @os = RSpec.configuration.os
  end
  @os
end