Class: Rutema::Configuration

Inherits:
Object
  • Object
show all
Includes:
ConfigurationDirectives
Defined in:
lib/rutema/core/configuration.rb

Overview

Class for reading, parsing and representing the configuration for a rutema test run

The instance will be passed around during testing and instruct each component which tests to execute how.

Rutema::ConfigurationDirectives defines all relevant methods and attributes.

Instance Attribute Summary collapse

Attributes included from ConfigurationDirectives

#context, #parser, #paths, #reporters, #runner, #setup, #suite_setup, #suite_teardown, #teardown, #tests, #tools

Instance Method Summary collapse

Methods included from ConfigurationDirectives

#init, #path=, #reporter=, #tool=

Constructor Details

#initialize(config_file) ⇒ Configuration

Create a new instance by parsing the given configuration file

  • config_file - the configuration file which shall be parsed on initializing the new instance


334
335
336
337
338
# File 'lib/rutema/core/configuration.rb', line 334

def initialize(config_file)
  @filename = config_file
  init
  load_configuration(@filename)
end

Instance Attribute Details

#filenameObject (readonly)

The filename of the root configuration file from which the Configuration instance was built



327
328
329
# File 'lib/rutema/core/configuration.rb', line 327

def filename
  @filename
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yield the instance itself if a block is given

This can be used e.g. in configuration files to execute a block on the Configuration instance itself (e.g. to modify it through the setter methods of the ConfigurationDirectives module).

Yields:

  • (_self)

Yield Parameters:



346
347
348
349
350
# File 'lib/rutema/core/configuration.rb', line 346

def configure
  return unless block_given?

  yield self
end

#import(filename) ⇒ Object

Load and import the configuration from a file

This method can be used to chain configuration files together.

Example

If there is a configuration file "main.rutema" which contains all the generic directives and several others which modify specific aspects, then the specialized configurations can import the "main.rutema" as follows:

import("main.rutema")


364
365
366
367
368
369
# File 'lib/rutema/core/configuration.rb', line 364

def import(filename)
  fnm = File.expand_path(filename)
  raise ConfigurationException, "Import error: Can't find #{fnm}" unless File.exist?(fnm)

  load_configuration(fnm)
end