class TextChecker

Constants

COMPARATORS

Public Instance Methods

check_assertion(key, input, config, example) click to toggle source
# File lib/checker.rb, line 18
def check_assertion(key, input, config, example)
  if key == :keys
    check_keys input, config, example
  else
    check_comparators key, input, config
  end
end
check_comparators(key, input, config) click to toggle source
# File lib/checker.rb, line 26
def check_comparators(key, input, config)
  COMPARATORS[key]
      .new(config.is_a?(Hash) ? config : {expected: config})
      .compare(input[:source])
      .try { |error| fail error }
end
check_keys(input, config, example) click to toggle source
# File lib/checker.rb, line 33
def check_keys(input, config, example)
  source_hash = YAML.load(input[:source]).with_indifferent_access
    config.each do |subkey, subconfig|
      check_assertions({source: source_hash[subkey]}, subconfig, example)
  end
end