Sha256: af6ffcf44417cf65d8852fcc1cad0c860f841f64b0ef1c4b3838e5224a898d31
Contents?: true
Size: 1015 Bytes
Versions: 10
Compression:
Stored size: 1015 Bytes
Contents
# frozen_string_literal: true module Spout module Tests # If a variable references a domain, then the domain should exist and be # defined. module DomainExistenceValidation 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))["domain"] domain_names.include?(domain_name) rescue JSON::ParserError domain_name = "" false end message = "The domain #{domain_name} referenced by #{item} does not exist." assert result, message end Dir.glob("variables/**/*.json").each do |file| if (not [nil, ""].include?(JSON.parse(File.read(file))["domain"]) rescue false) define_method("test_domain_exists: #{file}") do assert_domain_existence file end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems