Sha256: d56c06287add383299aedfd47d2f5585279e2584d9b092dfb04c75fe95838e70
Contents?: true
Size: 1.5 KB
Versions: 22
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe LHS::Record do context 'update' do before do class Record < LHS::Record endpoint 'http://datastore/records/{id}' end end it 'allows to directly update a record without fetching it first' do stub_request(:post, "http://datastore/records/123") .with(body: { name: 'Steve' }.to_json) .to_return(status: 200, body: {}.to_json) Record.update( id: '123', name: 'Steve' ) end it 'does not fail during an error with update' do stub_request(:post, "http://datastore/records/123") .with(body: { name: 'Steve' }.to_json) .to_return(status: 404, body: {}.to_json) record = Record.update( id: '123', name: 'Steve' ) expect(record.errors.status_code).to eq 404 end it 'allows to directly update! a record without fetching it first' do stub_request(:post, "http://datastore/records/123") .with(body: { name: 'Steve' }.to_json) .to_return(status: 200) Record.update!( id: '123', name: 'Steve' ) end it 'raises an error when trying to update! but retrieving an error status' do stub_request(:post, "http://datastore/records/123") .with(body: { name: 'Steve' }.to_json) .to_return(status: 404) expect(-> { Record.update!( id: '123', name: 'Steve' ) }).to raise_error(LHC::NotFound) end end end
Version data entries
22 entries across 22 versions & 1 rubygems