Sha256: aa9aa24d9caaca1fc721aa9ab66bef985f46212533048de9824d64fb5d5a86fb
Contents?: true
Size: 1.32 KB
Versions: 105
Compression:
Stored size: 1.32 KB
Contents
require 'rails_helper' describe LHS::Record do context 'cast nested data' do let(:datastore) { 'http://local.ch/v2' } before(:each) do LHC.config.placeholder('datastore', datastore) class Customer < LHS::Record endpoint ':datastore/customers' endpoint ':datastore/customers/:id' end class Contract < LHS::Record endpoint ':datastore/contracts' endpoint ':datastore/contracts/:id' end class Address < LHS::Record endpoint ':datastore/addresses' endpoint ':datastore/addresses/:id' end end it 'casts nested data properly' do stub_request(:get, "http://local.ch/v2/customers?limit=1") .to_return( body: { items: [ { href: "http://local.ch/v2/customers/12", address: { href: "http://local.ch/v2/addresses/3" }, contracts: [ { href: "http://local.ch/v2/contracts/2" } ] } ] }.to_json ) customer = Customer.first expect(customer).to be_kind_of Customer expect(customer.address).to be_kind_of Address expect(customer.contracts.first).to be_kind_of Contract end end end
Version data entries
105 entries across 105 versions & 1 rubygems