Sha256: 88f73c7fe6eb5cd1fee9971c7f453bfe493b3d65628c9459cd669985c8bb9ecf

Contents?: true

Size: 865 Bytes

Versions: 43

Compression:

Stored size: 865 Bytes

Contents

module Spout
  module Tests
    module DomainFormat

      def assert_domain_format(item, msg = nil)
        result = begin
          json = JSON.parse(File.read(item))
          if json.kind_of?(Array)
            json.empty? or json.select{|o| not o.kind_of?(Hash)}.size == 0
          else
            false
          end
        rescue JSON::ParserError
          false
        end

        full_message = build_message(msg, "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_block(full_message) do
          result
        end
      end

      Dir.glob("domains/**/*.json").each do |file|
        define_method("test_domain_format: "+file) do
          assert_domain_format file
        end
      end

    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
spout-0.8.0.beta13 lib/spout/tests/domain_format.rb
spout-0.8.0.beta12 lib/spout/tests/domain_format.rb
spout-0.8.0.beta11 lib/spout/tests/domain_format.rb
spout-0.8.0.beta10 lib/spout/tests/domain_format.rb
spout-0.8.0.beta9 lib/spout/tests/domain_format.rb
spout-0.8.0.beta8 lib/spout/tests/domain_format.rb
spout-0.8.0.beta7 lib/spout/tests/domain_format.rb
spout-0.8.0.beta6 lib/spout/tests/domain_format.rb
spout-0.8.0.beta5 lib/spout/tests/domain_format.rb
spout-0.8.0.beta4 lib/spout/tests/domain_format.rb
spout-0.8.0.beta3 lib/spout/tests/domain_format.rb
spout-0.8.0.beta2 lib/spout/tests/domain_format.rb
spout-0.8.0.beta1 lib/spout/tests/domain_format.rb
spout-0.7.0 lib/spout/tests/domain_format.rb
spout-0.7.0.beta3 lib/spout/tests/domain_format.rb
spout-0.7.0.beta2 lib/spout/tests/domain_format.rb
spout-0.7.0.beta1 lib/spout/tests/domain_format.rb
spout-0.6.0 lib/spout/tests/domain_format.rb
spout-0.6.0.rc2 lib/spout/tests/domain_format.rb
spout-0.6.0.rc lib/spout/tests/domain_format.rb