Parent

Class/Module Index [+]

Quicksearch

WebMock::RequestPattern

Attributes

body_pattern[R]
headers_pattern[R]
method_pattern[R]
uri_pattern[R]

Public Class Methods

new(method, uri, options = {}) click to toggle source
# File lib/webmock/request_pattern.rb, line 7
def initialize(method, uri, options = {})
  @method_pattern  = MethodPattern.new(method)
  @uri_pattern     = create_uri_pattern(uri)
  @body_pattern    = nil
  @headers_pattern = nil
  @with_block      = nil
  assign_options(options)
end

Public Instance Methods

matches?(request_signature) click to toggle source
# File lib/webmock/request_pattern.rb, line 22
def matches?(request_signature)
  content_type = request_signature.headers['Content-Type'] if request_signature.headers
  @method_pattern.matches?(request_signature.method) &&
    @uri_pattern.matches?(request_signature.uri) &&
    (@body_pattern.nil? || @body_pattern.matches?(request_signature.body, content_type || "")) &&
    (@headers_pattern.nil? || @headers_pattern.matches?(request_signature.headers)) &&
    (@with_block.nil? || @with_block.call(request_signature))
end
to_s() click to toggle source
# File lib/webmock/request_pattern.rb, line 31
def to_s
  string = "#{@method_pattern.to_s.upcase}"
  string << " #{@uri_pattern.to_s}"
  string << " with body #{@body_pattern.to_s}" if @body_pattern
  string << " with headers #{@headers_pattern.to_s}" if @headers_pattern
  string << " with given block" if @with_block
  string
end
with(options = {}, &block) click to toggle source
# File lib/webmock/request_pattern.rb, line 16
def with(options = {}, &block)
  assign_options(options)
  @with_block = block
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.