Module: Spout::Tests::DomainFormat
- Included in:
- Spout::Tests
- Defined in:
- lib/spout/tests/domain_format.rb
Instance Method Summary collapse
-
#assert_domain_format(item) ⇒ Object
Verifies the format of a domain.
Instance Method Details
#assert_domain_format(item) ⇒ Object
Verifies the format of a domain.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/spout/tests/domain_format.rb', line 7 def assert_domain_format(item) result = begin json = JSON.parse(File.read(item, encoding: "utf-8")) if json.is_a?(Array) json.empty? || json.select { |o| !o.is_a?(Hash) }.empty? else false end rescue JSON::ParserError false end = \ "Must be an array of choice hashes. Ex:\n[\n {\n \"value\": "\ " \"1\",\n \"display_name\": \"Option 1\",\n \"description\""\ ": \"...\"\n },\n { ... },\n ...\n]" assert result, end |