Sha256: 135c55231d790d635c00f88fed157d8538ba3d3e6dedc4b588620409120534cd
Contents?: true
Size: 807 Bytes
Versions: 1
Compression:
Stored size: 807 Bytes
Contents
module WildcardMatchers module Matchers def is_uri(hash = {}) IsUri.new(hash) end class IsUri < ::WildcardMatchers::WildcardMatcher protected def wildcard_match(actual) uri = nil begin require "addressable/uri" uri = ::Addressable::URI.parse(actual) # if actual is ::URI re-parse rescue LoadError require "uri" uri = actual.is_a?(URI) ? actual : ::URI.parse(actual) end begin expectation.each do |key, value| errors.push(*self.class.superclass.check_errors(uri.__send__(key), value, position + "[#key.inspect}]")) end rescue ::URI::Error errors.push("#{position}: expect #{actual} to be parsed as uri") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wildcard_matchers-0.1.1 | lib/wildcard_matchers/matchers/is_uri.rb |