class MnoeFaradayTestAdapter::Stub

Public Class Methods

new(full, headers, body, block) click to toggle source
Calls superclass method
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 100
def initialize(full, headers, body, block)
  path, query = full.split('?')
  params = query ?
    Faraday::Utils.parse_nested_query(query) :
    {}
  super(path, params, headers, body, block)
end

Public Instance Methods

headers_match?(request_headers) click to toggle source
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 136
def headers_match?(request_headers)
  headers.keys.all? do |key|
    request_headers[key] == headers[key]
  end
end
matches?(request_uri, request_headers, request_body) click to toggle source
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 108
def matches?(request_uri, request_headers, request_body)
  request_path, request_query = request_uri.split('?')
  request_params = request_query ?
    Faraday::Utils.parse_nested_query(request_query) :
    {}
  request_path == path &&
    params_match?(request_params) &&
    (body.to_s.size.zero? || request_body == body) &&
    headers_match?(request_headers)
end
params_deep_equal?(src,dst) click to toggle source
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 126
def params_deep_equal?(src,dst)
  src.keys.all? do |key|
    if src[key] && dst[key] && src[key].is_a?(Hash) && dst[key].is_a?(Hash)
      params_deep_equal?(src[key],dst[key])
    else
      (src[key] == '**' && dst[key]) || src[key] == dst[key]
    end
  end
end
params_match?(request_params) click to toggle source
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 119
def params_match?(request_params)
  params_deep_equal?(params,request_params)
  # params.keys.all? do |key|
  #   request_params[key] == params[key]
  # end
end
to_s() click to toggle source
# File lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb, line 142
def to_s
  "#{path} #{body}"
end