Module: Rutema::ConfigurationDirectives
- Included in:
- Configuration
- Defined in:
- lib/rutema/core/configuration.rb
Overview
Mix-in module defining all configuration directives available for rutema
Example
A configuration file needs at least definitions of which parser to utilize and which tests to run.
rutema configuration files are valid Ruby code and can use the full power of the language including require directives.
require "rake/file_list"
configure do |cfg|
cfg.parser = { :class => Rutema::Parsers::XML }
cfg.tests = FileList['all/of/the/tests/**/*.*']
end
Instance Attribute Summary collapse
-
#context ⇒ Object
Hash of context data which may be utilized throughout test runs.
-
#parser ⇒ Object
Parser class which shall be used to parse test specifications.
-
#paths ⇒ Object
readonly
A hash of supplementary paths identified by representative names.
-
#reporters ⇒ Object
A hash mapping reporter classes to supplementary definitions.
-
#runner ⇒ Object
Runner class which shall be used to execute the tests.
-
#setup ⇒ Object
Path to a setup specification which will be run before every test specification (optional).
-
#suite_setup ⇒ Object
(also: #check)
Path to a suite setup specification (optional).
-
#suite_teardown ⇒ Object
Path to a suite teardown specification (optional).
-
#teardown ⇒ Object
Path to a teardown specification which will be run after every test specification (optional).
-
#tests ⇒ Object
Array of (most probably the paths to) the specifications of the tests to be executed.
-
#tools ⇒ Object
readonly
Hash containing data for tools indexed by their names.
Instance Method Summary collapse
-
#init ⇒ Object
Initialize member variables which are needed to process a configuration.
-
#path=(definition) ⇒ Object
Add a path indexed by a representative name to the paths attribute.
-
#reporter=(definition) ⇒ Object
Add a reporter for the test execution.
-
#tool=(definition) ⇒ Object
Add a hash with arbitrary data concerning one particular tool which can be utilized throughout testing by accessing the
toolsattribute of classes including this module.
Instance Attribute Details
#context ⇒ Object
Hash of context data which may be utilized throughout test runs
This could be used for e.g. tester names, version numbers, etc.
29 30 31 |
# File 'lib/rutema/core/configuration.rb', line 29 def context @context end |
#parser ⇒ Object
Parser class which shall be used to parse test specifications
33 34 35 |
# File 'lib/rutema/core/configuration.rb', line 33 def parser @parser end |
#paths ⇒ Object (readonly)
A hash of supplementary paths identified by representative names
37 38 39 |
# File 'lib/rutema/core/configuration.rb', line 37 def paths @paths end |
#reporters ⇒ Object
A hash mapping reporter classes to supplementary definitions
41 42 43 |
# File 'lib/rutema/core/configuration.rb', line 41 def reporters @reporters end |
#runner ⇒ Object
Runner class which shall be used to execute the tests
45 46 47 |
# File 'lib/rutema/core/configuration.rb', line 45 def runner @runner end |
#setup ⇒ Object
Path to a setup specification which will be run before every test specification (optional)
50 51 52 |
# File 'lib/rutema/core/configuration.rb', line 50 def setup @setup end |
#suite_setup ⇒ Object Also known as: check
Path to a suite setup specification (optional)
This will be run before all other test specifications. If it fails no other specifications will be executed.
57 58 59 |
# File 'lib/rutema/core/configuration.rb', line 57 def suite_setup @suite_setup end |
#suite_teardown ⇒ Object
Path to a suite teardown specification (optional)
This will be run after all other test specifications
63 64 65 |
# File 'lib/rutema/core/configuration.rb', line 63 def suite_teardown @suite_teardown end |
#teardown ⇒ Object
Path to a teardown specification which will be run after every test specification (optional)
68 69 70 |
# File 'lib/rutema/core/configuration.rb', line 68 def teardown @teardown end |
#tests ⇒ Object
Array of (most probably the paths to) the specifications of the tests to be executed
In nearly all cases this would contain only paths but generally this can contain any data intelligible by the test specification parser.
76 77 78 |
# File 'lib/rutema/core/configuration.rb', line 76 def tests @tests end |
#tools ⇒ Object (readonly)
Hash containing data for tools indexed by their names
80 81 82 |
# File 'lib/rutema/core/configuration.rb', line 80 def tools @tools end |
Instance Method Details
#init ⇒ Object
Initialize member variables which are needed to process a configuration
264 265 266 267 268 269 270 |
# File 'lib/rutema/core/configuration.rb', line 264 def init @reporters = {} @context = {} @tests = [] @tools = OpenStruct.new @paths = OpenStruct.new end |
#path=(definition) ⇒ Object
Add a path indexed by a representative name to the paths attribute
A hash is expected which contains a representative name under the :name
key and the path itself under the :path key.
New calls only add to the hash. Later calls containing the same :name
key as earlier ones replace the data these set.
Example
configure do |cfg|
cfg.path = { :name => "doc", :path => "/usr/local/share/doc" }
end
122 123 124 125 126 127 |
# File 'lib/rutema/core/configuration.rb', line 122 def path=(definition) raise ConfigurationException, "required key :name is missing from #{definition}" unless definition[:name] raise ConfigurationException, "required key :path is missing from #{definition}" unless definition[:path] @paths[definition[:name]] = definition[:path] end |
#reporter=(definition) ⇒ Object
Add a reporter for the test execution
The only required key is :class which should be set to the fully
qualified name of the class to be used for reporting.
Multiple reporter classes can be set simultaneously.
Example
configure do |cfg|
cfg.reporters = { :class => Rutema::Reporters::Console }
cfg.reporters = { :class => Rutema::Reporters::JUnit }
end
256 257 258 259 260 |
# File 'lib/rutema/core/configuration.rb', line 256 def reporter=(definition) raise ConfigurationException, "required key :class is missing from #{definition}" unless definition[:class] @reporters[definition[:class]] = definition end |
#tool=(definition) ⇒ Object
Add a hash with arbitrary data concerning one particular tool which can be
utilized throughout testing by accessing the tools attribute of classes
including this module
The hash must include a :name key which will define the key under which
the entire passed hash will be stored.
New calls only add to the hash. Later calls containing the same :name
key as earlier ones replace the data these set.
Example
configure do |cfg|
cfg.tool = { :name => "nunit", :path => "/bin/nunit", :configuration => { :important=>"info" } }
end
The path to NUnit can be accessed the following way:
@configuration.tools["nunit"][:path]
102 103 104 105 106 |
# File 'lib/rutema/core/configuration.rb', line 102 def tool=(definition) raise ConfigurationException, "required key :name is missing from #{definition}" unless definition[:name] @tools[definition[:name]] = definition end |