Sha256: 645426566a25e063697057bf68eb96f51459b5b472eb2e3a6573268bb14e082c

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'rails_helper'

describe LHC::Endpoint do
  context 'match' do
    context 'matching' do
      it 'checks if a url matches a template' 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'
        }.each do |template, url|
          expect(
            described_class.match?(url, template)
          ).to be, "#{url} should match #{template}!"
        end
      end
    end

    context 'not matching' do
      it 'checks if a url matches a template' 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'
        }.each do |template, url|
          expect(
            described_class.match?(url, template)
          ).not_to be, "#{url} should not match #{template}!"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lhc-3.5.3 spec/endpoint/match_spec.rb
lhc-3.5.2 spec/endpoint/match_spec.rb