From c3c46a6d63450eefa70c9e0673df2a5be937ae5b Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Thu, 14 Jan 2016 10:44:50 +0000 Subject: [PATCH] Made sure we include the module name for SchemaParseErrors If you pass an unrecognized object for the schema, we should be raising a SchemaParseError, however instead right now a NameError is raised, beacuse we're not correctly qualifying the error class with it's module. I've corrected the class/module name and added tests. This fixes #292 --- lib/json-schema/validator.rb | 2 +- test/test_ruby_schema.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/json-schema/validator.rb b/lib/json-schema/validator.rb index a447fcc5..50b5b07f 100644 --- a/lib/json-schema/validator.rb +++ b/lib/json-schema/validator.rb @@ -569,7 +569,7 @@ def initialize_schema(schema) end Validator.add_schema(schema) else - raise SchemaParseError, "Invalid schema - must be either a string or a hash" + raise JSON::Schema::SchemaParseError, "Invalid schema - must be either a string or a hash" end schema diff --git a/test/test_ruby_schema.rb b/test/test_ruby_schema.rb index 7693b336..a6e884bd 100644 --- a/test/test_ruby_schema.rb +++ b/test/test_ruby_schema.rb @@ -56,4 +56,10 @@ def test_symbol_keys_in_hash_within_array assert_valid schema, data, :validate_schema => true end + + def test_schema_of_unrecognized_type + assert_raises JSON::Schema::SchemaParseError do + JSON::Validator.validate(Object.new, {}) + end + end end