Sha256: eb7a0e52ca816250b9e7e34ca9ebe9e49b690136ac5e40abebeefa0804d5acbc

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 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',
          ':datastore/entries/:id.json' => 'http://local.ch/entries/123.json'
        }.each do |template, url|
          expect(
            LHC::Endpoint.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',
          ':datastore/entries/:id' => 'http://local.ch/entries/123.json'
        }.each do |template, url|
          expect(
            LHC::Endpoint.match?(url, template)
          ).not_to be, "#{url} should not match #{template}!"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lhc-5.0.2 spec/endpoint/match_spec.rb
lhc-5.0.1 spec/endpoint/match_spec.rb
lhc-5.0.0 spec/endpoint/match_spec.rb
lhc-4.0.2 spec/endpoint/match_spec.rb
lhc-4.0.1 spec/endpoint/match_spec.rb
lhc-4.0.0 spec/endpoint/match_spec.rb
lhc-3.8.1 spec/endpoint/match_spec.rb
lhc-3.8.0 spec/endpoint/match_spec.rb
lhc-3.7.3 spec/endpoint/match_spec.rb
lhc-3.7.2 spec/endpoint/match_spec.rb
lhc-3.7.2.1 spec/endpoint/match_spec.rb
lhc-3.7.1 spec/endpoint/match_spec.rb
lhc-3.7.0 spec/endpoint/match_spec.rb
lhc-3.7.0.pre1 spec/endpoint/match_spec.rb
lhc-3.6.1 spec/endpoint/match_spec.rb
lhc-3.6.0 spec/endpoint/match_spec.rb
lhc-3.5.5 spec/endpoint/match_spec.rb