class WebMock::BodyPattern

Constants

BODY_FORMATS

Public Class Methods

new(pattern) click to toggle source
# File lib/webmock/request_pattern.rb, line 166
def initialize(pattern)
  @pattern = if pattern.is_a?(Hash)
    normalize_hash(pattern)
  elsif rSpecHashIncludingMatcher?(pattern)
    WebMock::Matchers::HashIncludingMatcher.from_rspec_matcher(pattern)
  else
    pattern
  end
end

Public Instance Methods

matches?(body, content_type = "") click to toggle source
# File lib/webmock/request_pattern.rb, line 176
def matches?(body, content_type = "")
  if (@pattern).is_a?(Hash)
    return true if @pattern.empty?
    matching_hashes?(body_as_hash(body, content_type), @pattern)
  elsif (@pattern).is_a?(WebMock::Matchers::HashIncludingMatcher)
    @pattern == body_as_hash(body, content_type)
  else
    empty_string?(@pattern) && empty_string?(body) ||
      @pattern == body ||
      @pattern === body
  end
end
to_s() click to toggle source
# File lib/webmock/request_pattern.rb, line 189
def to_s
  @pattern.inspect
end