Sha256: 1de834937db18768717c82de49bbe53688697a06bb88674da44dad10834b7219
Contents?: true
Size: 921 Bytes
Versions: 17
Compression:
Stored size: 921 Bytes
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::Record do let(:handler) { spy('handler') } before do class Record < LHS::Record endpoint 'http://local.ch/v2/records/{id}' end class NestedRecord < LHS::Record endpoint 'http://local.ch/v2/other_records/{id}' end stub_request(:get, "http://local.ch/v2/records/1") .to_return(body: { href: 'http://local.ch/v2/records/1', other: { href: 'http://local.ch/v2/other_records/2' } }.to_json) stub_request(:get, "http://local.ch/v2/other_records/2") .to_return(status: 404) end it 'allows to pass error_handling for includes to LHC' do handler = ->(_) { return { deleted: true } } record = Record.includes_first_page(:other).references(other: { rescue: { LHC::NotFound => handler } }).find(id: 1) expect(record.other.deleted).to be(true) end end
Version data entries
17 entries across 17 versions & 1 rubygems