Sha256: 6ceec899a68790e92e4ad5e5a8f1df0bd90951ec6e047fb1aa85338abaedb624

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 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

2 entries across 2 versions & 1 rubygems

Version Path
rspeckled-2.1.1 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb
rspeckled-2.1.0 lib/rspeckled/plugins/extensions/vcr/matchers/uri_without_trailing_id.rb