Skip to content

Commit

Permalink
Schema.new_schema: instantiate regardless of schema_content's type
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Jul 20, 2023
1 parent a8ffa91 commit 11eae3a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
4 changes: 1 addition & 3 deletions lib/jsi/schema.rb
Expand Up @@ -295,10 +295,8 @@ def new_schema(schema_content,
else
default_metaschema_new_schema.call
end
elsif [true, false].include?(schema_content)
default_metaschema_new_schema.call
else
raise(TypeError, "cannot instantiate Schema from: #{schema_content.pretty_inspect.chomp}")
default_metaschema_new_schema.call
end
end

Expand Down
5 changes: 0 additions & 5 deletions test/schema_test.rb
Expand Up @@ -12,11 +12,6 @@
assert_equal("given schema_content keyword `$schema` is not a string", err.message)
end

it 'cannot instantiate from some unknown object' do
err = assert_raises(TypeError) { JSI.new_schema(Object.new, default_metaschema: JSI::JSONSchemaOrgDraft07) }
assert_match(/\Acannot instantiate Schema from: #<Object:.*>\z/m, err.message)
end

it 'cannot instantiate from a JSI Schema' do
err = assert_raises(TypeError) { JSI.new_schema(JSI::JSONSchemaOrgDraft07.new_schema({}), default_metaschema: JSI::JSONSchemaOrgDraft07) }
assert_equal("Given schema_content is already a JSI::Schema. It cannot be instantiated as the content of a schema.\ngiven: \#{<JSI (JSI::JSONSchemaOrgDraft07) Schema>}", err.message)
Expand Down

0 comments on commit 11eae3a

Please sign in to comment.