Sha256: 86089eba5e4074bb3fa56d2540562071e061f1a50a2bed28c1a575d406c1c143

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 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'
        }.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'
          }.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

8 entries across 8 versions & 1 rubygems

Version Path
lhc-3.4.0 spec/endpoint/match_spec.rb
lhc-3.3.0 spec/endpoint/match_spec.rb
lhc-3.2.0 spec/endpoint/match_spec.rb
lhc-3.1.1 spec/endpoint/match_spec.rb
lhc-3.1.0 spec/endpoint/match_spec.rb
lhc-3.0.0 spec/endpoint/match_spec.rb
lhc-2.0.0 spec/endpoint/match_spec.rb
lhc-1.2.0 spec/endpoint/match_spec.rb