Class: VCR::RequestMatcherRegistry
- Inherits:
-
Object
- Object
- VCR::RequestMatcherRegistry
- Defined in:
- lib/vcr/request_matcher_registry.rb
Overview
Keeps track of the different request matchers.
Defined Under Namespace
Classes: Matcher, URIWithoutParamsMatcher
Constant Summary collapse
- DEFAULT_MATCHERS =
The default request matchers used for any cassette that does not specify request matchers.
[:method, :uri]
Instance Method Summary collapse
- #[](matcher) ⇒ Object
-
#initialize ⇒ RequestMatcherRegistry
constructor
A new instance of RequestMatcherRegistry.
- #register(name, &block) ⇒ Object
-
#uri_without_params(*ignores) ⇒ #call
(also: #uri_without_param)
Builds a dynamic request matcher that matches on a URI while ignoring the named query parameters.
Constructor Details
#initialize ⇒ RequestMatcherRegistry
Returns a new instance of RequestMatcherRegistry.
49 50 51 52 |
# File 'lib/vcr/request_matcher_registry.rb', line 49 def initialize @registry = {} register_built_ins end |
Instance Method Details
#[](matcher) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/vcr/request_matcher_registry.rb', line 64 def [](matcher) @registry.fetch(matcher) do matcher.respond_to?(:call) ? Matcher.new(matcher) : raise_unregistered_matcher_error(matcher) end end |
#register(name, &block) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/vcr/request_matcher_registry.rb', line 55 def register(name, &block) if @registry.has_key?(name) warn "WARNING: There is already a VCR request matcher registered for #{name.inspect}. Overriding it." end @registry[name] = Matcher.new(block) end |
#uri_without_params(*ignores) ⇒ #call Also known as: uri_without_param
Builds a dynamic request matcher that matches on a URI while ignoring the named query parameters. This is useful for dealing with non-deterministic URIs (i.e. that have a timestamp or request signature parameter).
91 92 93 |
# File 'lib/vcr/request_matcher_registry.rb', line 91 def uri_without_params(*ignores) uri_without_param_matchers[ignores] end |