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-15.2.1 spec/config/placeholders_spec.rb
lhc-15.2.0 spec/config/placeholders_spec.rb
lhc-15.1.3 spec/config/placeholders_spec.rb
lhc-15.1.2 spec/config/placeholders_spec.rb
lhc-15.1.1 spec/config/placeholders_spec.rb
lhc-15.1.0 spec/config/placeholders_spec.rb
lhc-16.0.0.pre.pro2162.2 spec/config/placeholders_spec.rb
lhc-16.0.0.pre.pro2162 spec/config/placeholders_spec.rb
lhc-15.0.1 spec/config/placeholders_spec.rb
lhc-15.0.0 spec/config/placeholders_spec.rb
lhc-14.0.0 spec/config/placeholders_spec.rb
lhc-13.4.0.pre.pro1766.1 spec/config/placeholders_spec.rb
lhc-13.2.0 spec/config/placeholders_spec.rb
lhc-13.1.0 spec/config/placeholders_spec.rb
lhc-13.0.0 spec/config/placeholders_spec.rb
lhc-12.3.0 spec/config/placeholders_spec.rb
lhc-12.2.1 spec/config/placeholders_spec.rb
lhc-12.2.0 spec/config/placeholders_spec.rb
lhc-12.1.3 spec/config/placeholders_spec.rb
lhc-12.1.2 spec/config/placeholders_spec.rb