Repository URL to install this package:
|
Version:
7.3.3 ▾
|
# frozen_string_literal: true
RSpec::Matchers.define :match_url do |expected|
if expected.is_a?(Regexp)
match { |actual| expect(actual).to match(expected) }
else
def url_to_hash(string)
url = URI.parse string
%i[scheme host path query fragment].to_h do |element|
[element, url.send(element)]
end.compact
end
match do |actual|
expected_components = url_to_hash(expected)
actual_components = url_to_hash(actual)
expect(actual_components).to include(**expected_components)
end
end
end