class Mocha::ParameterMatchers::EquivalentUri
Parameter matcher which matches URIs with equivalent query strings.
Public Class Methods
Source
# File lib/mocha/parameter_matchers/equivalent_uri.rb, line 31 def initialize(uri) @uri = URI.parse(uri) end
@private
Public Instance Methods
Source
# File lib/mocha/parameter_matchers/equivalent_uri.rb, line 36 def matches?(available_parameters) actual = explode(URI.parse(available_parameters.shift)) expected = explode(@uri) actual == expected end
@private
Source
# File lib/mocha/parameter_matchers/equivalent_uri.rb, line 43 def mocha_inspect "equivalent_uri(#{@uri.mocha_inspect})" end
@private
Private Instance Methods
Source
# File lib/mocha/parameter_matchers/equivalent_uri.rb, line 50 def explode(uri) query_hash = Hash.new { |hash, key| hash[key] = [] } URI.decode_www_form(uri.query || '').each do |key, value| query_hash[key] << value end URI::Generic::COMPONENT.inject({}) { |h, k| h.merge(k => uri.__send__(k)) }.merge(query: query_hash) end
@private