Class: RSpecPuppetUtils::HieraData::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_puppet_utils/hieradata/validator.rb

Direct Known Subclasses

YamlValidator

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/rspec_puppet_utils/hieradata/validator.rb', line 6

def data
  @data
end

#load_errorsObject (readonly)

Returns the value of attribute load_errors.



6
7
8
# File 'lib/rspec_puppet_utils/hieradata/validator.rb', line 6

def load_errors
  @load_errors
end

Instance Method Details

#validate(key, required_files = [], &block) ⇒ Object

Raises:



8
9
10
11
12
13
14
15
16
# File 'lib/rspec_puppet_utils/hieradata/validator.rb', line 8

def validate(key, required_files = [], &block)
  pre_checks(required_files)
  @found = false
  @data.keys.each do |file|
    validate_file file, key, required_files, &block
  end
  raise ValidationError, "No match for #{key.inspect} was not found in any files" unless @found
  raise ValidationError, "No match for #{key.inspect} was not found in: #{required_files.join ', '}" unless required_files.empty?
end