Sha256: 0ee80ceb1522e9ed5bf32b199b612caa84a33d72bd43c96e4b5d0a44df9cd9fd

Contents?: true

Size: 983 Bytes

Versions: 15

Compression:

Stored size: 983 Bytes

Contents

require 'rails_helper'

describe LHS::Service do

  let(:datastore) { 'http://local.ch/v2' }

  before(:each) do
    LHC.config.placeholder(:datastore, datastore)
    class SomeService < LHS::Service
      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))

      SomeService.first.source_id
    end

    it 'returns nil if no record was found' do
      stub_request(:get, "#{datastore}/feedbacks?limit=1")
        .to_return(status: 404)
      expect(SomeService.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 { SomeService.first! }.to raise_error LHC::NotFound
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lhs-2.2.2 spec/service/first_spec.rb
lhs-1.6.1 spec/service/first_spec.rb
lhs-2.2.1 spec/service/first_spec.rb
lhs-2.2.0 spec/service/first_spec.rb
lhs-1.6.0 spec/service/first_spec.rb
lhs-2.1.1 spec/service/first_spec.rb
lhs-2.1.0 spec/service/first_spec.rb
lhs-2.0.5 spec/service/first_spec.rb
lhs-2.0.4 spec/service/first_spec.rb
lhs-2.0.3 spec/service/first_spec.rb
lhs-2.0.2 spec/service/first_spec.rb
lhs-2.0.1 spec/service/first_spec.rb
lhs-2.0.0 spec/service/first_spec.rb
lhs-1.5.0 spec/service/first_spec.rb
lhs-1.4.0 spec/service/first_spec.rb