Sha256: 65d6fa13cd2571d515de61d13dba8cdc2786427a4220f6be9dcf35023f27eee9

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

require 'rails_helper'

describe LHS::Record do
  let(:datastore) { 'http://local.ch/v2' }

  before do
    LHC.config.placeholder(:datastore, datastore)
    class Record < LHS::Record
      endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
      endpoint '{+datastore}/feedbacks'
    end
  end

  context 'first' do
    it 'finds a single record' do
      stub_request(:get, "#{datastore}/feedbacks?limit=1")
        .to_return(status: 200, body: load_json(:feedback))
      record = Record.first
      expect(record).to be_kind_of Record
      expect(record.source_id).to be_present
    end

    it 'returns nil if no record was found' do
      stub_request(:get, "#{datastore}/feedbacks?limit=1")
        .to_return(status: 404)
      expect(Record.first).to be_nil
    end
  end

  context 'first!' do
    it 'raises if nothing was found with parameters' do
      stub_request(:get, "#{datastore}/feedbacks?limit=1")
        .to_return(status: 404)
      expect { Record.first! }.to raise_error LHC::NotFound
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lhs-16.1.5 spec/record/first_spec.rb
lhs-16.1.4 spec/record/first_spec.rb
lhs-16.1.3 spec/record/first_spec.rb
lhs-16.1.2 spec/record/first_spec.rb
lhs-16.1.1 spec/record/first_spec.rb
lhs-16.1.0 spec/record/first_spec.rb
lhs-16.0.1 spec/record/first_spec.rb
lhs-16.0.0 spec/record/first_spec.rb
lhs-15.7.0 spec/record/first_spec.rb
lhs-15.6.1 spec/record/first_spec.rb
lhs-15.6.0 spec/record/first_spec.rb
lhs-15.5.1 spec/record/first_spec.rb
lhs-15.5.0 spec/record/first_spec.rb
lhs-15.4.1 spec/record/first_spec.rb
lhs-15.4.0 spec/record/first_spec.rb
lhs-15.4.0.pre.hasone.1 spec/record/first_spec.rb
lhs-15.3.3 spec/record/first_spec.rb
lhs-15.3.3.pre.fixoptions.1 spec/record/first_spec.rb
lhs-15.3.2 spec/record/first_spec.rb