Sha256: 4b809525f3bed0dca44fd750f7536abc38704c69b91cc56dcd627790afb1336a

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 Bytes

Contents

require 'rails_helper'

describe LHS::Service do

  context 'set options for an endpoint' do

    before(:each) do
      class SomeService < LHS::Service
        endpoint 'backend/v2/feedbacks/:id', cache_expires_in: 1.day, retry: 2, cache: true
      end
    end

    it 'stores endpoints with options' do
      expect(SomeService.endpoints[0].options).to eq(cache_expires_in: 86400, retry: 2, cache: true)
    end

    it 'uses the options that are configured for an endpoint' do
      expect(LHC).to receive(:request).with(cache_expires_in: 1.day, retry: 2, cache: true, url: 'backend/v2/feedbacks/1').and_call_original
      stub_request(:get, "http://backend/v2/feedbacks/1").to_return(status: 200)
      SomeService.find(1)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lhs-2.2.2 spec/service/endpoint_options_spec.rb
lhs-2.2.1 spec/service/endpoint_options_spec.rb
lhs-2.2.0 spec/service/endpoint_options_spec.rb
lhs-2.1.1 spec/service/endpoint_options_spec.rb
lhs-2.1.0 spec/service/endpoint_options_spec.rb