Sha256: d117c52ccd5dc24777873e22dba6b118d07111a22c1c4f292573dd086aa116a1
Contents?: true
Size: 1.99 KB
Versions: 59
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::Record do context 'merge' do before do class Change < LHS::Record endpoint 'https://onboarding/places/{id}/change' end end it 'merges a given hash' do stub_request(:get, "https://onboarding/places/1/change") .to_return(body: { entry: { name: 'Steve', address: 'Zurich' }, products: ['LBP'] }.to_json) record = Change.find(1) record.merge!(entry: { name: 'Paul' }) expect(record.entry.name).to eq 'Paul' expect(record.entry.address).to eq nil expect(record.products.to_a).to eq ['LBP'] end it 'merges! a given hash' do stub_request(:get, "https://onboarding/places/1/change") .to_return(body: { entry: { name: 'Steve', address: 'Zurich' }, products: ['LBP'] }.to_json) record = Change.find(1) new_record = record.merge(entry: { name: 'Paul' }) expect(new_record.entry.name).to eq 'Paul' expect(new_record.entry.address).to eq nil expect(new_record.products.to_a).to eq ['LBP'] expect(record.entry.name).to eq 'Steve' expect(record.entry.address).to eq 'Zurich' expect(record.products.to_a).to eq ['LBP'] end it 'deep_merge! a given hash' do stub_request(:get, "https://onboarding/places/1/change") .to_return(body: { entry: { name: 'Steve', address: 'Zurich' } }.to_json) record = Change.find(1) record.deep_merge!(entry: { name: 'Paul' }) expect(record.entry.name).to eq 'Paul' expect(record.entry.address).to eq 'Zurich' end it 'deep_merge a given hash' do stub_request(:get, "https://onboarding/places/1/change") .to_return(body: { entry: { name: 'Steve', address: 'Zurich' } }.to_json) record = Change.find(1) new_record = record.deep_merge(entry: { name: 'Paul' }) expect(new_record.entry.name).to eq 'Paul' expect(new_record.entry.address).to eq 'Zurich' expect(record.entry.name).to eq 'Steve' end end end
Version data entries
59 entries across 59 versions & 1 rubygems