Sha256: 09b08d229d294a11ab0025d828f278878a76d34c5512d68e0b8bb4cfa8f9400f
Contents?: true
Size: 1.23 KB
Versions: 19
Compression:
Stored size: 1.23 KB
Contents
require 'rails_helper' describe LHS::Record do before do class Record < LHS::Record endpoint 'http://datastore/records' endpoint 'http://datastore/records/{id}' end class AnotherRecord < LHS::Record endpoint 'http://datastore/otherrecords' endpoint 'http://datastore/otherrecords/{id}' def id another_id end end end context 'reload!' do it 'reloads the record by id' do stub_request(:post, "http://datastore/records") .to_return(body: { id: 1, name: 'Steve' }.to_json) record = Record.create!(name: 'Steve') stub_request(:get, "http://datastore/records/1") .to_return(body: { id: 1, name: 'Steve', async: 'data' }.to_json) record.reload! expect(record.async).to eq 'data' end it 'reloads the record by id if a record method defines the actual id' do stub_request(:post, "http://datastore/otherrecords") .to_return(body: { another_id: 2, name: 'Can' }.to_json) record = AnotherRecord.create!(name: 'Can') stub_request(:get, "http://datastore/otherrecords/2") .to_return(body: { id: 2, name: 'Can', async: 'data' }.to_json) record.reload! expect(record.async).to eq 'data' end end end
Version data entries
19 entries across 19 versions & 1 rubygems