Class: Fulmar::Domain::Service::ConfigTestService
- Inherits:
-
Object
- Object
- Fulmar::Domain::Service::ConfigTestService
- Includes:
- Model
- Defined in:
- lib/fulmar/domain/service/config_test_service.rb
Overview
Tests the configuration
Instance Method Summary collapse
- #global_test(name, &block) ⇒ Object
-
#initialize(config) ⇒ ConfigTestService
constructor
A new instance of ConfigTestService.
-
#run ⇒ Object
Runs all methods beginning with test_ and returns the report.
- #target_test(name, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ ConfigTestService
Returns a new instance of ConfigTestService.
11 12 13 14 |
# File 'lib/fulmar/domain/service/config_test_service.rb', line 11 def initialize(config) @config = config @tests = {} end |
Instance Method Details
#global_test(name, &block) ⇒ Object
32 33 34 |
# File 'lib/fulmar/domain/service/config_test_service.rb', line 32 def global_test(name, &block) @tests[name] = block end |
#run ⇒ Object
Runs all methods beginning with test_ and returns the report
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fulmar/domain/service/config_test_service.rb', line 37 def run test_files.each do |file| eval File.read(file) end results = [] @tests.each_pair do |name, test| results << test.call(@config) end results.reject!(&:nil?) results.reject!(&:empty?) results.flatten! results end |
#target_test(name, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fulmar/domain/service/config_test_service.rb', line 16 def target_test(name, &block) @tests[name] = proc do results = [] @config.each do |env, target, _data| @config.set env, target result = yield(@config) if result result[:message] = "in [#{env}:#{target}]: #{result[:message]}" results << result end end results.reject(&:nil?) end end |