Sha256: 0169e57bd14b6fc2e977dfed394917b1dee7811a916fe0eb0e2248dcfc2c7261

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

module SpecInfra
  module Configuration
    class << self
      VALID_OPTIONS_KEYS = [
        :path,
        :pre_command,
        :stdout,
        :stderr,
        :sudo_path,
        :disable_sudo,
        :pass_prompt,
        :sudo_options
      ].freeze

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

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
specinfra-0.3.2 lib/specinfra/configuration.rb
specinfra-0.3.1 lib/specinfra/configuration.rb
specinfra-0.3.0 lib/specinfra/configuration.rb
specinfra-0.2.1 lib/specinfra/configuration.rb