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

VALID_CONFIG_KEYS =
{
  authentication_hydrators: {
    base: Gruf::Rspec::AuthenticationHydrators::Base,
    basic: Gruf::Rspec::AuthenticationHydrators::Basic
  },
  rpc_spec_path: ENV.fetch('RPC_SPEC_PATH', '/spec/rpc/').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



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

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:



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

def configure
  yield self
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)

    The configuration for gruf, represented as a Hash



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

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



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

def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send((k.to_s + '='), v)
  end
  self.rpc_spec_path = '/spec/rpc/'
  options
end