Sha256: 01ab46d31aafb677e1f72cef5ebbe2825f475b3d43fd2e39a26984061b4397d2

Contents?: true

Size: 1.8 KB

Versions: 49

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC::Endpoint do
  context 'match' do
    context 'matching' do
      {
        '{+datastore}/v2/places' => 'http://local.ch:8082/v2/places',
        '{+datastore}/v2/places/{id}' => 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A',
        '{+datastore}/v2/places/{namespace}/{id}' => 'http://local.ch:8082/v2/places/switzerland/ZW9OJyrbt',
        '{+datastore}/addresses/{id}' => 'http://local.ch/addresses/123',
        'http://local.ch/addresses/{id}' => 'http://local.ch/addresses/123',
        '{+datastore}/customers/{id}/addresses' => 'http://local.ch:80/server/rest/v1/customers/123/addresses',
        '{+datastore}/entries/{id}.json' => 'http://local.ch/entries/123.json',
        '{+datastore}/places/{place_id}/feedbacks' => 'http://local.ch/places/1/feedbacks?limit=10&offset=0',
        'http://local.ch/places/1/feedbacks' => 'http://local.ch/places/1/feedbacks?lang=en',
        'http://local.ch/places/1/feedbacks.json' => 'http://local.ch/places/1/feedbacks.json?lang=en'
      }.each do |template, url|
        it "#{url} matches #{template}" do
          expect(LHC::Endpoint.match?(url, template)).to be(true)
        end
      end
    end

    context 'not matching' do
      {
        '{+datastore}/v2/places' => 'http://local.ch:8082/v2/places/ZW9OJyrbt4OZE9ueu80w-A',
        '{+datastore}/{campaign_id}/feedbacks' => 'http://datastore.local.ch/feedbacks',
        '{+datastore}/customers/{id}' => 'http://local.ch:80/server/rest/v1/customers/123/addresses',
        '{+datastore}/entries/{id}' => 'http://local.ch/entries/123.json'
      }.each do |template, url|
        it "#{url} should not match #{template}" do
          expect(
            LHC::Endpoint.match?(url, template)
          ).to be(false)
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
lhc-15.2.1 spec/endpoint/match_spec.rb
lhc-15.2.0 spec/endpoint/match_spec.rb
lhc-15.1.3 spec/endpoint/match_spec.rb
lhc-15.1.2 spec/endpoint/match_spec.rb
lhc-15.1.1 spec/endpoint/match_spec.rb
lhc-15.1.0 spec/endpoint/match_spec.rb
lhc-16.0.0.pre.pro2162.2 spec/endpoint/match_spec.rb
lhc-16.0.0.pre.pro2162 spec/endpoint/match_spec.rb
lhc-15.0.1 spec/endpoint/match_spec.rb
lhc-15.0.0 spec/endpoint/match_spec.rb
lhc-14.0.0 spec/endpoint/match_spec.rb
lhc-13.4.0.pre.pro1766.1 spec/endpoint/match_spec.rb
lhc-13.2.0 spec/endpoint/match_spec.rb
lhc-13.1.0 spec/endpoint/match_spec.rb
lhc-13.0.0 spec/endpoint/match_spec.rb
lhc-12.3.0 spec/endpoint/match_spec.rb
lhc-12.2.1 spec/endpoint/match_spec.rb
lhc-12.2.0 spec/endpoint/match_spec.rb
lhc-12.1.3 spec/endpoint/match_spec.rb
lhc-12.1.2 spec/endpoint/match_spec.rb