Class Index [+]

Quicksearch

Mocha::ParameterMatchers::QueryStringMatches

Parameter matcher which matches URIs with equivalent query strings.

Public Class Methods

new(uri) click to toggle source

@private

    # File lib/mocha/parameter_matchers/query_string.rb, line 33
33:       def initialize(uri)
34:         @uri = URI.parse(uri)
35:       end

Public Instance Methods

matches?(available_parameters) click to toggle source

@private

    # File lib/mocha/parameter_matchers/query_string.rb, line 38
38:       def matches?(available_parameters)
39:         actual = explode(URI.parse(available_parameters.shift))
40:         expected = explode(@uri)
41:         actual == expected
42:       end
mocha_inspect() click to toggle source

@private

    # File lib/mocha/parameter_matchers/query_string.rb, line 45
45:       def mocha_inspect
46:         "has_equivalent_query_string(#{@uri.mocha_inspect})"
47:       end

Private Instance Methods

explode(uri) click to toggle source

@private

    # File lib/mocha/parameter_matchers/query_string.rb, line 51
51:       def explode(uri)
52:         query_hash = (uri.query || '').split('&').inject({}){ |h, kv| h.merge(Hash[*kv.split('=')]) }
53:         URI::Generic::COMPONENT.inject({}){ |h, k| h.merge(k => uri.__send__(k)) }.merge(:query => query_hash)
54:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.