Skip to content

Commit

Permalink
SchemaClasses.module_for_schema ensures its argument is a schema, rat…
Browse files Browse the repository at this point in the history
…her than new_schema-ing it
  • Loading branch information
notEthan committed Feb 23, 2021
1 parent a522c1c commit fd8682c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/jsi/schema_classes.rb
Expand Up @@ -79,8 +79,8 @@ def bootstrap_schema_class(modules)
#
# defines a singleton method #schema to access the {JSI::Schema} this module represents, and extends
# the module with {JSI::SchemaModule}.
def module_for_schema(schema_object)
schema = JSI.new_schema(schema_object)
def module_for_schema(schema)
Schema.ensure_schema(schema)
jsi_memoize(:module_for_schema, schema) do |schema|
Module.new.tap do |m|
m.module_eval do
Expand Down
4 changes: 2 additions & 2 deletions test/base_test.rb
Expand Up @@ -73,8 +73,8 @@
# same module every time
assert_equal(JSI::SchemaClasses.module_for_schema(schema), module_for_schema)
end
it 'returns a module from a hash' do
assert_equal(JSI::SchemaClasses.module_for_schema(schema), JSI::SchemaClasses.module_for_schema(schema.jsi_instance))
it 'raises given a nonschema' do
assert_raises(JSI::Schema::NotASchemaError) { JSI::SchemaClasses.module_for_schema(schema_content) }
end
end
describe 'initialization' do
Expand Down

0 comments on commit fd8682c

Please sign in to comment.