Class: Polytrix::Manifest
- Inherits:
-
ManifestSection
- Object
- Hashie::Dash
- Dash
- ManifestSection
- Polytrix::Manifest
- Includes:
- Hashie::Extensions::DeepMerge, DefaultLogger, Logging
- Defined in:
- lib/polytrix/manifest.rb
Overview
Polytrix::Manifest acts as a test manifest. It defines the test scenarios that should be run, and may be shared across multiple implementors when used for a compliance suite.
A manifest is generally defined and loaded from YAML. Here’s an example manifest:
---
global_env:
LOCALE: <%= ENV['LANG'] %>
FAVORITE_NUMBER: 5
suites:
Katas:
env:
NAME: 'Max'
samples:
- hello world
- quine
Tutorials:
env:
samples:
- deploying
- documenting
The suites object defines the tests. Each object, under suites, like Katas or Tutorials in this example, represents a test suite. A test suite is subdivided into samples, that each act as a scenario. The global_env object and the env under each suite define (and standardize) the input for each test. The global_env values will be made available to all tests as environment variables, along with the env values for that specific test.
Defined Under Namespace
Classes: Environment, Suite
Instance Attribute Summary collapse
-
#challenges ⇒ Object
Returns the value of attribute challenges.
Class Method Summary collapse
-
.from_yaml(yaml_file) ⇒ Object
Parses a YAML file to create a Manifest object.
Instance Method Summary collapse
- #build_challenges ⇒ Object
-
#initialize(hash = {}) ⇒ Manifest
constructor
A new instance of Manifest.
Methods included from DefaultLogger
Methods included from DefaultLogger::ClassMethods
Constructor Details
#initialize(hash = {}) ⇒ Manifest
Returns a new instance of Manifest.
39 40 41 42 43 44 |
# File 'lib/polytrix/manifest.rb', line 39 def initialize(hash = {}) super implementors.each do | name, implementor | implementor.name = name end end |
Instance Attribute Details
#challenges ⇒ Object
Returns the value of attribute challenges.
65 66 67 |
# File 'lib/polytrix/manifest.rb', line 65 def challenges @challenges end |
Class Method Details
.from_yaml(yaml_file) ⇒ Object
Parses a YAML file to create a Polytrix::Manifest object.
81 82 83 84 85 86 87 88 |
# File 'lib/polytrix/manifest.rb', line 81 def self.from_yaml(yaml_file) ENV['POLYTRIX_SEED'] ||= $PROCESS_ID.to_s logger.debug "Loading #{yaml_file}" raw_content = File.read(yaml_file) processed_content = ERB.new(raw_content).result data = YAML.load processed_content new data end |
Instance Method Details
#build_challenges ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/polytrix/manifest.rb', line 67 def build_challenges @challenges ||= Challenges.new suites.each do | suite_name, suite | suite.samples.each do | sample | implementors.each_value do | implementor | challenge = implementor.build_challenge suite: suite_name, name: sample, vars: suite.env @challenges[challenge.slug] = challenge end end end end |