Sha256: ff95223325e9a07665f6bd5bb09740175cdd8741b5aaeca2d4e11666b1e18ec7
Contents?: true
Size: 1.16 KB
Versions: 12
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe DHS::Record do context 'destroy' do before do class Record < DHS::Record endpoint 'http://datastore/history' endpoint 'http://datastore/history/{id}' end end let(:entry) { { what: 'Cafe', where: 'Zurich' } } it 'allows to destroy by parameters directly' do stub_request(:delete, 'http://datastore/history?what=Cafe&where=Zurich') .to_return(body: [entry].to_json) deleted_entries = Record.destroy(what: 'Cafe', where: 'Zurich') expect(deleted_entries.first.to_h).to eq entry end it 'allows to destroy by id' do stub_request(:delete, 'http://datastore/history/1') .to_return(body: entry.to_json) deleted_entry = Record.destroy(1) expect(deleted_entry.to_h).to eq entry end it 'chains' do stub_request(:delete, 'http://datastore/history/1') .with(headers: { 'Authorization' => 'Bearer 123' }) .to_return(body: entry.to_json) deleted_entry = Record.options(headers: { 'Authorization' => 'Bearer 123' }).destroy(1) expect(deleted_entry.to_h).to eq entry end end end
Version data entries
12 entries across 12 versions & 1 rubygems