5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/spout/tests/domain_existence_validation.rb', line 5
def assert_domain_existence(item, msg = nil)
domain_names = Dir.glob("domains/**/*.json").collect{|file| file.split('/').last.to_s.downcase.split('.json').first}
result = begin
domain_name = JSON.parse(File.read(item))["domain"]
domain_names.include?(domain_name)
rescue JSON::ParserError
domain_name = ''
false
end
full_message = build_message(msg, "The domain #{domain_name} referenced by ? does not exist.", item)
assert_block(full_message) do
result
end
end
|