Method: VCR::Configuration#filter_sensitive_data
- Defined in:
- lib/vcr/configuration.rb
#filter_sensitive_data {|interaction| ... } ⇒ Object
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.
237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/vcr/configuration.rb', line 237 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 |