Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
uoy-faculty-spec-helpers / lib / faculty / custom_matchers.rb
Size: Mime:
# 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