Skip to content

Commit

Permalink
test hash instance with a complex default value
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Feb 18, 2020
1 parent bb04f69 commit a2aa34c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/base_hash_test.rb
Expand Up @@ -26,7 +26,7 @@
let(:schema) { JSI::Schema.new(schema_content) }
let(:subject) { schema.new_jsi(instance) }

describe '#[] with a default that is a basic type' do
describe '#[] with a schema default that is a basic type' do
let(:schema_content) do
{
'type' => 'object',
Expand Down Expand Up @@ -55,7 +55,7 @@
end
end
end
describe '#[] with a default that is a nonbasic type' do
describe '#[] with a schema default that is a nonbasic type' do
let(:schema_content) do
{
'type' => 'object',
Expand Down Expand Up @@ -85,6 +85,23 @@
end
end
end
describe '#[] with a hash default that is a nonbasic type' do
let(:schema_content) do
{
'type' => 'object',
'properties' => {
'foo' => {},
},
}
end
describe 'default value' do
let(:instance) { Hash.new({'foo' => 2}).merge({'bar' => 3}) }
it 'returns the default value' do
assert_is_a(Hash, subject.foo)
assert_equal({'foo' => 2}, subject.foo)
end
end
end
describe 'hashlike []=' do
it 'sets a property' do
orig_foo = subject['foo']
Expand Down

0 comments on commit a2aa34c

Please sign in to comment.