Class: VCR::HTTPInteraction::HookAware

Inherits:
VCR::HTTPInteraction show all
Defined in:
lib/vcr/structs.rb

Overview

Decorates an VCR::HTTPInteraction with additional methods useful for a before_record or before_playback hook.

Instance Attribute Summary

Attributes inherited from VCR::HTTPInteraction

#recorded_at, #request, #response

Instance Method Summary collapse

Methods inherited from VCR::HTTPInteraction

from_hash, #hook_aware, #to_hash

Constructor Details

#initialize(http_interaction) ⇒ HookAware

Returns a new instance of HookAware.



478
479
480
481
# File 'lib/vcr/structs.rb', line 478

def initialize(http_interaction)
  @ignored = false
  super
end

Instance Method Details

#filter!(text, replacement_text) ⇒ Object

Replaces a string in any part of the HTTP interaction (headers, request body, response body, etc) with the given replacement text.

Parameters:

  • text (String)

    the text to replace

  • replacement_text (String)

    the text to put in its place



502
503
504
505
# File 'lib/vcr/structs.rb', line 502

def filter!(text, replacement_text)
  return self if [text, replacement_text].any? { |t| t.to_s.empty? }
  filter_object!(self, text, replacement_text)
end

#ignore!Object

Flags the HTTP interaction so that VCR ignores it. This is useful in a Configuration#before_record or Configuration#before_playback hook so that VCR does not record or play it back.

See Also:



487
488
489
# File 'lib/vcr/structs.rb', line 487

def ignore!
  @ignored = true
end

#ignored?Boolean

Returns whether or not this HTTP interaction should be ignored.

Returns:

  • (Boolean)

    whether or not this HTTP interaction should be ignored.

See Also:



493
494
495
# File 'lib/vcr/structs.rb', line 493

def ignored?
  !!@ignored
end