Skip to content

Commit

Permalink
Add logging of filter_sensitive_data hooks.
Browse files Browse the repository at this point in the history
This should help with troubleshooting vcr#137.
  • Loading branch information
myronmarston committed Feb 26, 2012
1 parent c857d4d commit a0ea7b9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/vcr/configuration.rb
Expand Up @@ -4,8 +4,9 @@
module VCR
# Stores the VCR configuration.
class Configuration
include VCR::Hooks
include VCR::VariableArgsBlockCaller
include Hooks
include VariableArgsBlockCaller
include Logger

# The directory to read cassettes from and write cassettes to.
#
Expand Down Expand Up @@ -168,11 +169,15 @@ def register_request_matcher(name, &block)
# @yieldreturn the string to replace
def define_cassette_placeholder(placeholder, tag = nil, &block)
before_record(tag) do |interaction|
interaction.filter!(call_block(block, interaction), placeholder)
orig_text = call_block(block, interaction)
log "before_record: replacing #{orig_text.inspect} with #{placeholder.inspect}"
interaction.filter!(orig_text, placeholder)
end

before_playback(tag) do |interaction|
interaction.filter!(placeholder, call_block(block, interaction))
orig_text = call_block(block, interaction)
log "before_playback: replacing #{placeholder.inspect} with #{orig_text.inspect}"
interaction.filter!(placeholder, orig_text)
end
end
alias filter_sensitive_data define_cassette_placeholder
Expand Down Expand Up @@ -442,6 +447,10 @@ def register_built_in_hooks
end
end

def log_prefix
"[VCR::Configuration] "
end

# @private
define_hook :after_library_hooks_loaded
end
Expand Down

0 comments on commit a0ea7b9

Please sign in to comment.