require 'test/unit'
require File.dirname(__FILE__) + '/../lib/json-schema'

class RelativeDefinitionTest < Test::Unit::TestCase

  def test_definition_schema
    schema = File.join(File.dirname(__FILE__),"schemas/definition_schema.json")
    data = {"a" => 5}
    errors = JSON::Validator.fully_validate(schema,data, :errors_as_objects => true)
    assert(errors.empty?, errors.map{|e| e[:message] }.join("\n"))
  end

  def test_relative_definition
    schema = File.join(File.dirname(__FILE__),"schemas/relative_definition_schema.json")

    data = {"a" => "foo"}
    assert(!JSON::Validator.validate(schema,data))

    data = {"a" => 5}
    assert(JSON::Validator.validate(schema,data))
  end

end

require File.expand_path('../test_helper', __FILE__)

class RelativeDefinitionTest < MiniTest::Unit::TestCase

  def test_definition_schema
    assert_valid schema_fixture_path('definition_schema.json'), {"a" => 5}
  end

  def test_relative_definition
    schema = schema_fixture_path('relative_definition_schema.json')
    assert_valid schema, {"a" => 5}
    refute_valid schema, {"a" => "foo"}
  end

end

Update new test to use test_helper
Update new test to use test_helper
