Sha256: 1051a6508b8cb40c34b4e1c7cd29d3bab0262369e27e54e264f009b8053f4423

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'minitest/autorun'
require 'webmock/minitest'

$:.unshift(File.expand_path('../../lib', __FILE__))
require 'json-schema'

Dir[File.join(File.expand_path('../support', __FILE__), '*.rb')].each do |support_file|
  require support_file
end

class Minitest::Test
  def schema_fixture_path(filename)
    File.join(File.dirname(__FILE__), 'schemas', filename)
  end

  def data_fixture_path(filename)
    File.join(File.dirname(__FILE__), 'data', filename)
  end

  def assert_valid(schema, data, options = {})
    if !options.key?(:version) && respond_to?(:schema_version)
      options = options.merge(:version => schema_version)
    end

    errors = JSON::Validator.fully_validate(schema, data, options)
    assert_equal([], errors, "#{data.inspect} should be valid for schema:\n#{schema.inspect}")
  end

  def refute_valid(schema, data, options = {})
    if !options.key?(:version) && respond_to?(:schema_version)
      options = options.merge(:version => schema_version)
    end

    errors = JSON::Validator.fully_validate(schema, data, options)
    refute_equal([], errors, "#{data.inspect} should be invalid for schema:\n#{schema.inspect}")
  end

  def parser_error
    if defined?(::Yajl)
      Yajl::ParseError
    elsif defined?(::MultiJson)
      MultiJson::ParseError
    else
      JSON::ParserError
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
json-schema-openc-fork-0.0.2 test/test_helper.rb
json-schema-2.5.1 test/test_helper.rb
json-schema-openc-fork-0.0.1 test/test_helper.rb
json-schema-2.5.0 test/test_helper.rb