Module: Gruf::Rspec::Configuration

Included in:
Gruf::Rspec
Defined in:
lib/gruf/rspec/configuration.rb

Overview

Represents configuration settings for the system

Constant Summary collapse

DEFAULT_RSPEC_PATH =
'/spec/rpc/'
VALID_CONFIG_KEYS =
{
  authentication_hydrators: {
    base: Gruf::Rspec::AuthenticationHydrators::Base,
    basic: Gruf::Rspec::AuthenticationHydrators::Basic
  },
  rpc_spec_path: ENV.fetch('RPC_SPEC_PATH', DEFAULT_RSPEC_PATH).to_s
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Whenever this is extended into a class, setup the defaults



39
40
41
# File 'lib/gruf/rspec/configuration.rb', line 39

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Gruf::Rspec::Configuration

Yield self for ruby-style initialization

Yields:

  • (_self)

Yield Parameters:

Returns:



49
50
51
# File 'lib/gruf/rspec/configuration.rb', line 49

def configure
  yield self
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)

    The configuration for gruf, represented as a Hash



58
59
60
61
62
63
64
# File 'lib/gruf/rspec/configuration.rb', line 58

def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end

#resetHash

Set the default configuration onto the extended class

Returns:

  • (Hash)

    options The reset options hash



71
72
73
74
75
76
77
# File 'lib/gruf/rspec/configuration.rb', line 71

def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send("#{k}=", v)
  end
  self.rpc_spec_path = ::ENV.fetch('RPC_SPEC_PATH', DEFAULT_RSPEC_PATH).to_s
  options
end