Sha256: 3ac1686e881fd8aa205bc679407bf6b717ea5033e9aef2145799269efb4a5afa

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 Bytes

Contents

require 'spec_helper'

module Pacto
  describe UriPattern do
    context 'with non-strict matchers' do
      it 'returns a regex containing the host and path' do
        Pacto.configuration.strict_matchers = false
        request = double(host: 'myhost.com', path: '/stuff')
        expect(UriPattern.for(request).to_s).to eq(/myhost\.com\/stuff/.to_s)
      end

      it 'turns segments preceded by : into wildcards' do
        Pacto.configuration.strict_matchers = false
        request = double(host: 'myhost.com', path: '/:id')
        wildcard = '[^\/\?#]+'
        expect(UriPattern.for(request).to_s).to eq(/myhost\.com\/#{wildcard}/.to_s)
      end
    end

    context 'with strict matchers' do
      it 'returns a string with the host and path' do
        Pacto.configuration.strict_matchers = true
        request = double(host: 'myhost.com', path: '/stuff')
        expect(UriPattern.for(request)).to eq('myhost.com/stuff')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.3.1 spec/unit/pacto/stubs/uri_pattern_spec.rb
pacto-0.3.0 spec/unit/pacto/stubs/uri_pattern_spec.rb