Sha256: 50ca6b4c7a78d60ed195e8ed386d11b5119dbc4dde462dca3a3eb0eeece1906d

Contents?: true

Size: 1.01 KB

Versions: 130

Compression:

Stored size: 1.01 KB

Contents

require 'rails_helper'

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

  before(:each) 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
    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

130 entries across 130 versions & 1 rubygems

Version Path
lhs-14.6.5 spec/record/first_spec.rb
lhs-14.6.4 spec/record/first_spec.rb
lhs-14.6.3 spec/record/first_spec.rb
lhs-14.6.2 spec/record/first_spec.rb
lhs-14.6.1 spec/record/first_spec.rb
lhs-14.6.0 spec/record/first_spec.rb
lhs-14.5.0 spec/record/first_spec.rb
lhs-14.4.0 spec/record/first_spec.rb
lhs-14.3.4 spec/record/first_spec.rb
lhs-14.3.3 spec/record/first_spec.rb
lhs-14.3.2 spec/record/first_spec.rb
lhs-14.3.1 spec/record/first_spec.rb
lhs-14.3.0 spec/record/first_spec.rb
lhs-14.2.0 spec/record/first_spec.rb
lhs-14.1.1 spec/record/first_spec.rb
lhs-14.1.0 spec/record/first_spec.rb
lhs-14.0.3 spec/record/first_spec.rb
lhs-14.0.2 spec/record/first_spec.rb
lhs-14.0.1 spec/record/first_spec.rb
lhs-14.0.0 spec/record/first_spec.rb