Class: CemAcpt::TestData::Fetcher

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/test_data.rb

Overview

Fetcher provides the methods for extracting and formatting test data.

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

current_log_config, #current_log_config, current_log_format, #current_log_format, current_log_level, #current_log_level, included, logger, #logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level, new_logger, #new_logger

Constructor Details

#initialize(config) ⇒ Fetcher

Initializes a new Fetcher object.

Parameters:



26
27
28
29
30
# File 'lib/cem_acpt/test_data.rb', line 26

def initialize(config)
  @config = config
  @module_dir = config.get('module_dir')
  @acceptance_tests = find_acceptance_tests(config.get('module_dir'))
end

Instance Attribute Details

#acceptance_testsObject (readonly)

Returns the value of attribute acceptance_tests.



22
23
24
# File 'lib/cem_acpt/test_data.rb', line 22

def acceptance_tests
  @acceptance_tests
end

#module_dirObject (readonly)

Returns the value of attribute module_dir.



22
23
24
# File 'lib/cem_acpt/test_data.rb', line 22

def module_dir
  @module_dir
end

Instance Method Details

#acceptance_test_dataArray<Hash>

Extracts, formats, and returns a test data hash.

Returns:

  • (Array<Hash>)

    an array of test data hashes



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cem_acpt/test_data.rb', line 34

def acceptance_test_data
  logger.info 'Gathering acceptance test data...'
  acceptance_tests.each_with_object([]) do |t, a|
    logger.debug("Processing #{t}...")
    test_name = File.basename(t, '_spec.rb')
    test_data = {
      test_name: test_name,
      test_file: File.expand_path(t),
    }
    next unless @config.has?('tests') && @config.get('tests').include?(test_name)

    process_for_each(test_data).each do |test_data_i|
      process_static_vars(test_data_i)
      process_name_pattern_vars(test_name, test_data_i)
      vars_post_processing!(test_data_i)
      test_data_i.format!
      a << test_data_i
    end
  end
end