Sha256: e316281ee4e4ccb65b6c13f6fc6c5202fdf2d2a704f31227f70f709f5bf58880
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' RSpec.describe JSON::SchemaBuilder::Schema, type: :unit do let(:schema){ described_class.new a: 1, b: { c: 3 }, array: [123, { foo: 1, bar: { baz: 0 }}] } let(:other){ described_class.new a: 2, "b" => { d: 4 }, array: [456, { foo: 2, bar: { qux: 1 }}] } let(:merged) do { "a" => 2, "b" => { "c" => 3, "d" => 4 }, "array" => [ 123, { "foo" => 1, "bar" => { "baz" => 0, } }, 456, { "foo" => 2, "bar" => { "qux" => 1 } } ] } end its(:data){ is_expected.to be_a(HashWithIndifferentAccess) } describe '#merge' do it 'should deep merge' do merged_schema = schema.merge other expect(merged_schema).to be_a described_class expect(merged_schema.data).to eql merged end it 'should not modify the source schema' do expect{ schema.merge other }.to_not change{ schema.data } end it 'should not modify the merging schema' do expect{ schema.merge other }.to_not change{ other.data } end end describe '#merge!' do it 'should deep merge in place' do merged_schema = schema.merge! other expect(merged_schema).to be_a described_class expect(merged_schema.data).to eql merged end it 'should not modify the merging schema' do expect{ schema.merge! other }.to_not change { other.data } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json-schema_builder-0.3.1 | spec/unit/schema_spec.rb |