Sha256: 83c8ecf793738338235bbd770bb16e5b26fd7ef84e1bc9e8623dafb09ae6cf15

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require "vcr"

VCR.configure do |c|
  c.cassette_library_dir = 'test/cassettes'
  c.hook_into :webmock
  # c.debug_logger = File.open("logs/vcr.log", 'w')
  c.filter_sensitive_data('<OAuth Credentials>') do |interaction|
    interaction.request.headers['Authorization'].first
  end

  # hack hack hack
  # Couldn't work out how to instruct VCR to filter urls, shortUrls
  # and shortLinks from the returned body string; hate myself.
  c.filter_sensitive_data('<Trello URL>') do |interaction|
    parsed = JSON.parse(interaction.response.body)
    if parsed.is_a?(Array)
      parsed.map do |hash|
        hash.map do |k, v|
          hash[k] = "<Trello URL>" if (k == "url"      ||
                                       k == "shortUrl" ||
                                       k == "shortLink")
        end
      end
      interaction.response.body = JSON.dump(parsed)
    elsif parsed.is_a?(Hash)
      parsed.map do |k, v|
        parsed[k] = "<Trello URL>" if (k == "url"      ||
                                       k == "shortUrl" ||
                                       k == "shortLink")
      end
      interaction.response.body = JSON.dump(parsed)
    end
    nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
troo-0.0.7 test/support/vcr_setup.rb
troo-0.0.6 test/support/vcr_setup.rb
troo-0.0.5 test/support/vcr_setup.rb
troo-0.0.4 test/support/vcr_setup.rb
troo-0.0.3 test/support/vcr_setup.rb
troo-0.0.2 test/support/vcr_setup.rb