Sha256: 7008b9028706200381734b02d76372be338c9bcdb23ab626779f009ff4f3ba43

Contents?: true

Size: 1.14 KB

Versions: 49

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC do
  context 'configuration of placeholders' do
    it 'uses values for placeholders defined globally' do
      LHC.configure { |c| c.placeholder(:datastore, 'http://datastore/v2') }
      stub_request(:get, "http://datastore/v2/feedbacks")
      LHC.get('{+datastore}/feedbacks')
    end

    it 'uses explicit values first' do
      LHC.configure { |c| c.placeholder(:campaign_id, '123') }
      stub_request(:get, 'http://datastore/v2/campaign/456/feedbacks')
      url = 'http://datastore/v2/campaign/{campaign_id}/feedbacks'
      LHC.get(url, params: { campaign_id: '456' })
    end

    it 'raises in case of claching placeholder name' do
      LHC.configure { |c| c.placeholder(:datastore, 'http://datastore') }
      expect(lambda {
        LHC.config.placeholder(:datastore, 'http://datastore')
      }).to raise_error 'Placeholder already exists for that name'
    end

    it 'enforces placeholder name to be a symbol' do
      LHC.configure { |c| c.placeholder('datatore', 'http://datastore') }
      expect(LHC.config.placeholders[:datatore]).to eq 'http://datastore'
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
lhc-10.4.0 spec/config/placeholders_spec.rb
lhc-10.3.0 spec/config/placeholders_spec.rb
lhc-10.2.1 spec/config/placeholders_spec.rb
lhc-10.2.0 spec/config/placeholders_spec.rb
lhc-10.1.8 spec/config/placeholders_spec.rb
lhc-10.1.7 spec/config/placeholders_spec.rb
lhc-10.1.6 spec/config/placeholders_spec.rb
lhc-10.1.5 spec/config/placeholders_spec.rb
lhc-10.1.3 spec/config/placeholders_spec.rb