Parent

Files

WebMock::RequestPattern

Public Class Methods

new(method, uri, options = {}) click to toggle source
   # File lib/webmock/request_pattern.rb, line 5
5:     def initialize(method, uri, options = {})
6:       @method_pattern = MethodPattern.new(method)
7:       @uri_pattern = create_uri_pattern(uri)
8:       assign_options(options)
9:     end

Public Instance Methods

matches?(request_signature) click to toggle source
    # File lib/webmock/request_pattern.rb, line 17
17:     def matches?(request_signature)
18:       content_type = request_signature.headers['Content-Type'] if request_signature.headers
19:       @method_pattern.matches?(request_signature.method) &&
20:         @uri_pattern.matches?(request_signature.uri) &&
21:         (@body_pattern.nil? || @body_pattern.matches?(request_signature.body, content_type || "")) &&
22:         (@headers_pattern.nil? || @headers_pattern.matches?(request_signature.headers)) &&
23:         (@with_block.nil? || @with_block.call(request_signature))
24:     end
to_s() click to toggle source
    # File lib/webmock/request_pattern.rb, line 26
26:     def to_s
27:       string = "#{@method_pattern.to_s.upcase}"
28:       string << " #{@uri_pattern.to_s}"
29:       string << " with body #{@body_pattern.to_s}" if @body_pattern
30:       string << " with headers #{@headers_pattern.to_s}" if @headers_pattern
31:       string << " with given block" if @with_block
32:       string
33:     end
with(options = {}, &block) click to toggle source
    # File lib/webmock/request_pattern.rb, line 11
11:     def with(options = {}, &block)
12:       assign_options(options)
13:       @with_block = block
14:       self
15:     end

Private Instance Methods

assign_options(options) click to toggle source
    # File lib/webmock/request_pattern.rb, line 38
38:     def assign_options(options)
39:       @body_pattern = BodyPattern.new(options[:body]) if options.has_key?(:body)
40:       @headers_pattern = HeadersPattern.new(options[:headers]) if options.has_key?(:headers)
41:       @uri_pattern.add_query_params(options[:query]) if options.has_key?(:query)
42:     end
create_uri_pattern(uri) click to toggle source
    # File lib/webmock/request_pattern.rb, line 44
44:     def create_uri_pattern(uri)
45:       if uri.is_a?(Regexp)
46:         URIRegexpPattern.new(uri)
47:       else
48:         URIStringPattern.new(uri)
49:       end
50:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.