Class: VCR::HeaderMatcher
- Inherits:
-
Struct
- Object
- Struct
- VCR::HeaderMatcher
- Defined in:
- lib/vcr/header_matcher.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
Returns the value of attribute keys.
Instance Method Summary collapse
- #human_type ⇒ Object
- #matches?(request, expected_request) ⇒ Boolean
- #only_keys ⇒ Object
- #without_keys ⇒ Object
Instance Attribute Details
#keys ⇒ Object
Returns the value of attribute keys
2 3 4 |
# File 'lib/vcr/header_matcher.rb', line 2 def keys @keys end |
Instance Method Details
#human_type ⇒ Object
34 35 36 |
# File 'lib/vcr/header_matcher.rb', line 34 def human_type "" end |
#matches?(request, expected_request) ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vcr/header_matcher.rb', line 3 def matches?(request, expected_request) requested_headers = request.headers expected_headers = expected_request.headers if only_keys.present? requested_headers.slice!(*only_keys) expected_headers.slice!(*only_keys) end if without_keys.present? requested_headers.except!(*without_keys) expected_headers.except!(*without_keys) end requested_headers == expected_headers end |
#only_keys ⇒ Object
27 28 29 30 31 32 |
# File 'lib/vcr/header_matcher.rb', line 27 def only_keys keys.map do |k| prefix, key_name = k.split(/^\^/) prefix if prefix.present? end.compact end |
#without_keys ⇒ Object
20 21 22 23 24 25 |
# File 'lib/vcr/header_matcher.rb', line 20 def without_keys keys.map do |k| prefix, key_name = k.split(/^\^/) key_name if key_name.present? end.compact end |