class Brutal::Configuration

Brutal::Configuration

@since 1.0.0

Constants

DEFAULT_ACTUALS
DEFAULT_CONTEXTS
DEFAULT_HEAD
DEFAULT_SUBJECT

Attributes

actuals[R]

Specifies templates to challenge evaluated subjects & get results.

contexts[R]

Specifies a list of variables to populate the subject's template.

header[R]

Specifies the code to execute before generating the test suite.

subject[R]

Specifies the template of the code to be declined across contexts.

Public Class Methods

load(params) click to toggle source

Load the configuration parameters.

@param params [Hash] Receive the 4 top-level section parameters.

# File lib/brutal/configuration.rb, line 16
def self.load(params)
  new(
    actuals:  params.fetch("actuals", DEFAULT_ACTUALS),
    contexts: params.fetch("contexts", DEFAULT_CONTEXTS),
    header:   params.fetch("header", DEFAULT_HEAD),
    subject:  params.fetch("subject", DEFAULT_SUBJECT)
  )
end
new(actuals:, contexts:, header:, subject:) click to toggle source

Initialize a new configuration.

# File lib/brutal/configuration.rb, line 38
def initialize(actuals:, contexts:, header:, subject:)
  raise ::TypeError, actuals.inspect  unless actuals.is_a?(::Array)
  raise ::TypeError, contexts.inspect unless contexts.is_a?(::Hash)
  raise ::TypeError, header.inspect   unless header.is_a?(::String)
  raise ::TypeError, subject.inspect  unless subject.is_a?(::String)

  @actuals  = actuals.sort
  @contexts = contexts
  @header   = header
  @subject  = subject
end