Sha256: 5cb127747139234a02ecd4d370e3faec6a5e7ab6cea69c001bfe99d03703ae56

Contents?: true

Size: 876 Bytes

Versions: 13

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

module  Rspeckled
module  Vcr
module  Matchers
class   UriWithoutTrailingId
  attr_accessor :trailing_id_matcher

  def initialize(trailing_id_matcher)
    self.trailing_id_matcher = trailing_id_matcher
  end

  def call(request, vcr_cassette_request)
    request_uri              = request.uri
    vcr_cassette_request_uri = vcr_cassette_request.uri

    if request_uri.match?(trailing_id_matcher)
      request_uri_without_id              = request_uri.sub(trailing_id_matcher, '')
      vcr_cassette_request_uri_without_id = vcr_cassette_request_uri.sub(trailing_id_matcher, '')

      request_uri.match(trailing_id_matcher) &&
      vcr_cassette_request_uri.match(trailing_id_matcher) &&
      request_uri_without_id == vcr_cassette_request_uri_without_id
    else
      request_uri == vcr_cassette_request_uri
    end
  end
end
end
end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rspeckled-2.0.1 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-2.0.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.4.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.3.1 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.3.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.2.1 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.2.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.1.3 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.1.2 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.1.1 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.1.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.0.5 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-1.0.4 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb