Module: Spout::Tests::DomainExistenceValidation
- Included in:
- Spout::Tests
- Defined in:
- lib/spout/tests/domain_existence_validation.rb
Overview
If a variable references a domain, then the domain should exist and be defined.
Instance Method Summary collapse
Instance Method Details
#assert_domain_existence(item) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spout/tests/domain_existence_validation.rb', line 8 def assert_domain_existence(item) domain_names = Dir.glob("domains/**/*.json").collect do |file| file.split("/").last.to_s.downcase.split(".json").first end result = begin domain_name = JSON.parse(File.read(item, encoding: "utf-8"))["domain"] domain_names.include?(domain_name) rescue JSON::ParserError domain_name = "" false end = "The domain #{domain_name} referenced by #{item} does not exist." assert result, end |