Class: TextChecker
- Inherits:
-
Mumukit::Metatest::Checker
- Object
- Mumukit::Metatest::Checker
- TextChecker
show all
- Defined in:
- lib/checker.rb
Defined Under Namespace
Modules: IgnoreCase, IgnoreWhitespace, LenientBlank, Multiline
Classes: Comparator, ContainComparator, EqualityComparator, RegexpComparator, ValidIpComparator
Constant Summary
collapse
- COMPARATORS =
{
match: TextChecker::RegexpComparator,
equal: TextChecker::EqualityComparator,
contain: TextChecker::ContainComparator,
valid_ip: TextChecker::ValidIpComparator
}
Instance Method Summary
collapse
Instance Method Details
#check_assertion(key, input, config, example) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/checker.rb', line 20
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) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/checker.rb', line 28
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) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/checker.rb', line 35
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
|