Class: Brutal::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/brutal/configuration.rb

Overview

Brutal::Configuration

Since:

  • 1.0.0

Constant Summary collapse

DEFAULT_ACTUALS =

Since:

  • 1.0.0

[].freeze
DEFAULT_CONTEXTS =

Since:

  • 1.0.0

{}.freeze
DEFAULT_HEAD =

Since:

  • 1.0.0

'# Brutal test suite'
DEFAULT_SUBJECT =

Since:

  • 1.0.0

''

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actuals:, contexts:, header:, subject:) ⇒ Configuration

Initialize a new configuration.

Raises:

  • (::TypeError)

Since:

  • 1.0.0



38
39
40
41
42
43
44
45
46
47
48
# 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
  @contexts = contexts
  @header   = header
  @subject  = subject
end

Instance Attribute Details

#actualsObject (readonly)

Specifies templates to challenge evaluated subjects & get results.

Since:

  • 1.0.0



26
27
28
# File 'lib/brutal/configuration.rb', line 26

def actuals
  @actuals
end

#contextsObject (readonly)

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

Since:

  • 1.0.0



29
30
31
# File 'lib/brutal/configuration.rb', line 29

def contexts
  @contexts
end

#headerObject (readonly)

Specifies the code to execute before generating the test suite.

Since:

  • 1.0.0



32
33
34
# File 'lib/brutal/configuration.rb', line 32

def header
  @header
end

#subjectObject (readonly)

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

Since:

  • 1.0.0



35
36
37
# File 'lib/brutal/configuration.rb', line 35

def subject
  @subject
end

Class Method Details

.load(params) ⇒ Object

Load the configuration parameters.

Since:

  • 1.0.0



16
17
18
19
20
21
22
23
# 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