Sha256: 1542f4cd1443e2def03ab937d0b5d4beec73fad4cbbcb5da1144031c684885d4

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

require 'rails_helper'

describe LHS::Record do
  context 'destroy' do
    before(:each) do
      class Record < LHS::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

16 entries across 16 versions & 1 rubygems

Version Path
lhs-15.3.1 spec/record/destroy_spec.rb
lhs-15.3.1.pre.fixlhc.1 spec/record/destroy_spec.rb
lhs-15.3.0 spec/record/destroy_spec.rb
lhs-15.2.5 spec/record/destroy_spec.rb
lhs-15.2.4 spec/record/destroy_spec.rb
lhs-15.2.3 spec/record/destroy_spec.rb
lhs-15.2.3.pre.favorites.1 spec/record/destroy_spec.rb
lhs-15.2.2.pre.favorites.1 spec/record/destroy_spec.rb
lhs-15.2.2 spec/record/destroy_spec.rb
lhs-15.2.1 spec/record/destroy_spec.rb
lhs-15.2.0 spec/record/destroy_spec.rb
lhs-15.1.1 spec/record/destroy_spec.rb
lhs-15.1.0 spec/record/destroy_spec.rb
lhs-15.0.2 spec/record/destroy_spec.rb
lhs-15.0.1 spec/record/destroy_spec.rb
lhs-15.0.0 spec/record/destroy_spec.rb