test/schema_test.rb in jsi-0.1.0 vs test/schema_test.rb in jsi-0.2.0
- old
+ new
@@ -15,11 +15,11 @@
assert_equal(schema_node, schema.schema_object)
end
it 'initializes from a JSI' do
schema_jsi = SomeMetaschema.new('type' => 'object')
schema = JSI::Schema.new(schema_jsi)
- assert_equal(schema_jsi.instance, schema.schema_node)
+ assert_equal(schema_jsi, schema.schema_node)
assert_equal(schema_jsi, schema.schema_object)
end
it 'cannot instantiate from some unknown object' do
err = assert_raises(TypeError) { JSI::Schema.new(Object.new) }
assert_match(/\Acannot instantiate Schema from: #<Object:.*>\z/m, err.message)
@@ -165,30 +165,30 @@
end
describe 'validation' do
let(:schema) { JSI::Schema.new({id: 'https://schemas.jsi.unth.net/test/validation', type: 'object'}) }
describe 'without errors' do
let(:instance) { {'foo' => 'bar'} }
- it '#fully_validate' do
- assert_equal([], schema.fully_validate(instance))
+ it '#fully_validate_instance' do
+ assert_equal([], schema.fully_validate_instance(instance))
end
- it '#validate' do
- assert_equal(true, schema.validate(instance))
+ it '#validate_instance' do
+ assert_equal(true, schema.validate_instance(instance))
end
- it '#validate!' do
- assert_equal(true, schema.validate!(instance))
+ it '#validate_instance!' do
+ assert_equal(true, schema.validate_instance!(instance))
end
end
describe 'with errors' do
let(:instance) { ['no'] }
- it '#fully_validate' do
- assert_equal(["The property '#/' of type array did not match the following type: object in schema https://schemas.jsi.unth.net/test/validation"], schema.fully_validate(instance))
+ it '#fully_validate_instance' do
+ assert_equal(["The property '#/' of type array did not match the following type: object in schema https://schemas.jsi.unth.net/test/validation"], schema.fully_validate_instance(instance))
end
- it '#validate' do
- assert_equal(false, schema.validate(instance))
+ it '#validate_instance' do
+ assert_equal(false, schema.validate_instance(instance))
end
- it '#validate!' do
+ it '#validate_instance!' do
err = assert_raises(JSON::Schema::ValidationError) do
- schema.validate!(instance)
+ schema.validate_instance!(instance)
end
assert_equal("The property '#/' of type array did not match the following type: object", err.message)
end
end
end