class Vacuum::Matcher
Custom VCR matcher for stubbing calls to the Product Advertising API
The matcher is not required by default.
@example
require 'vacuum/matcher' # in your test VCR.insert_cassette('cassette_name', match_requests_on: [Vacuum::Matcher])
@see relishapp.com/vcr/vcr/v/5-0-0/docs/request-matching/register-and-use-a-custom-matcher
Constants
- IGNORED_KEYS
Attributes
requests[R]
@!visibility private
Public Class Methods
call(*requests)
click to toggle source
@!visibility private
# File lib/vacuum/matcher.rb, line 26 def self.call(*requests) new(*requests).compare end
new(*requests)
click to toggle source
@!visibility private
# File lib/vacuum/matcher.rb, line 31 def initialize(*requests) @requests = requests end
Public Instance Methods
compare()
click to toggle source
@!visibility private
# File lib/vacuum/matcher.rb, line 36 def compare uris.reduce(:==) && bodies.reduce(:==) end
Private Instance Methods
bodies()
click to toggle source
# File lib/vacuum/matcher.rb, line 46 def bodies requests.map do |req| params = JSON.parse(req.body) IGNORED_KEYS.each { |k| params.delete(k) } params end end
uris()
click to toggle source
# File lib/vacuum/matcher.rb, line 42 def uris requests.map(&:uri) end