Class: Brutal::Configuration
- Inherits:
-
Object
- Object
- Brutal::Configuration
- Defined in:
- lib/brutal/configuration.rb
Overview
Brutal::Configuration
Constant Summary collapse
- ACTUALS_KEY =
"actuals"
- CONTEXTS_KEY =
"contexts"
- HEADER_KEY =
"header"
- SUBJECT_KEY =
"subject"
- DEFAULT_ACTUALS =
[].freeze
- DEFAULT_CONTEXTS =
{}.freeze
- DEFAULT_HEADER =
"# Brutal test suite"
- DEFAULT_SUBJECT =
""
Instance Attribute Summary collapse
-
#actuals ⇒ Object
readonly
Specifies templates to challenge evaluated subjects & get results.
-
#contexts ⇒ Object
readonly
Specifies a list of variables to populate the subject’s template.
-
#header ⇒ Object
readonly
Specifies the code to execute before generating the test suite.
-
#subject ⇒ Object
readonly
Specifies the template of the code to be declined across contexts.
Class Method Summary collapse
-
.load(params) ⇒ Object
Load the configuration parameters.
Instance Method Summary collapse
-
#initialize(actuals:, contexts:, header:, subject:) ⇒ Configuration
constructor
Initialize a new configuration.
Constructor Details
#initialize(actuals:, contexts:, header:, subject:) ⇒ Configuration
Initialize a new configuration.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/brutal/configuration.rb', line 43 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 |
Instance Attribute Details
#actuals ⇒ Object (readonly)
Specifies templates to challenge evaluated subjects & get results.
31 32 33 |
# File 'lib/brutal/configuration.rb', line 31 def actuals @actuals end |
#contexts ⇒ Object (readonly)
Specifies a list of variables to populate the subject’s template.
34 35 36 |
# File 'lib/brutal/configuration.rb', line 34 def contexts @contexts end |
#header ⇒ Object (readonly)
Specifies the code to execute before generating the test suite.
37 38 39 |
# File 'lib/brutal/configuration.rb', line 37 def header @header end |
#subject ⇒ Object (readonly)
Specifies the template of the code to be declined across contexts.
40 41 42 |
# File 'lib/brutal/configuration.rb', line 40 def subject @subject end |
Class Method Details
.load(params) ⇒ Object
Load the configuration parameters.
21 22 23 24 25 26 27 28 |
# File 'lib/brutal/configuration.rb', line 21 def self.load(params) new( actuals: params.fetch(ACTUALS_KEY, DEFAULT_ACTUALS), contexts: params.fetch(CONTEXTS_KEY, DEFAULT_CONTEXTS), header: params.fetch(HEADER_KEY, DEFAULT_HEADER), subject: params.fetch(SUBJECT_KEY, DEFAULT_SUBJECT) ) end |