Skip to content

Commit

Permalink
Made sure we include the module name for SchemaParseErrors
Browse files Browse the repository at this point in the history
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 voxpupuli#292
  • Loading branch information
Iain Beeston committed Jan 14, 2016
1 parent 597952b commit c3c46a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/json-schema/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/test_ruby_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c3c46a6

Please sign in to comment.