Method: VCR::Configuration#define_cassette_placeholder
- Defined in:
- lib/vcr/configuration.rb
#define_cassette_placeholder(placeholder, tag = nil) {|interaction| ... } ⇒ Object Also known as: filter_sensitive_data
Sets up a #before_record and a #before_playback hook that will insert a placeholder string in the cassette in place of another string. You can use this as a generic way to interpolate a variable into the cassette for a unique string. It’s particularly useful for unique sensitive strings like API keys and passwords.
225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/vcr/configuration.rb', line 225 def define_cassette_placeholder(placeholder, tag = nil, &block) before_record(tag) do |interaction| 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| orig_text = call_block(block, interaction) log "before_playback: replacing #{orig_text.inspect} with #{placeholder.inspect}" interaction.filter!(placeholder, orig_text) end end |