lib/spout/tests/domain_format.rb
# Verifies the format of a domain.
Verifies the format of a domain.
Verifies the format of a domain .
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
        message = \
          "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, message
      end
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 message = "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 , message end
Verifies the format of a domain.
Verifies the format of a domain .
item
<not_specific>