Sha256: 048e54147231d671f3d4652b01098ba258b877e12ab26fcbdb575944b94f5304

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

require "vcr"

VCR.configure do |vcr|
  vcr.cassette_library_dir = File.join(File.dirname(__FILE__), "../cassettes")
  vcr.allow_http_connections_when_no_cassette = false
  vcr.hook_into :webmock

  vcr.configure_rspec_metadata!
  vcr.default_cassette_options = {
    :record => :none,
    #:record => :new_episodes,
    :match_requests_on => [:method, :path, :body],
    :update_content_length_header => true
  }

  # Gives lots of clues about how VCR is running
  # vcr.debug_logger = $stderr

  vcr.before_record do |interaction|
    host = URI.parse(interaction.request.uri).host
    interaction.request.uri.gsub!(host, "api.brightbox.dev")

    # Sanitise identifiers as best as we can
    # We need the poser of Regexp so filter_sensitive doesn't help
    %w(acc col cip fwp fwr grp img lba srv typ usr zon).each do |prefix|
      id_pattern = /#{prefix}-[0-9a-z]+/
      interaction.request.uri.gsub!(id_pattern, "#{prefix}-12345")
      interaction.request.body.gsub!(id_pattern, "#{prefix}-12345")
      interaction.response.body.gsub!(id_pattern, "#{prefix}-12345")
    end
  end
end

VCR.turn_off!

VCR.extend Module.new {
  def use_cassette(*args)
    VCR.turn_on!
    super
    VCR.turn_off!
  end
}

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 spec/support/vcr.rb
brightbox-cli-3.2.0 spec/support/vcr.rb
brightbox-cli-3.1.0 spec/support/vcr.rb
brightbox-cli-3.0.1 spec/support/vcr.rb
brightbox-cli-3.0.0 spec/support/vcr.rb
brightbox-cli-2.12.0 spec/support/vcr.rb
brightbox-cli-2.11.2 spec/support/vcr.rb
brightbox-cli-2.11.1 spec/support/vcr.rb
brightbox-cli-2.11.0 spec/support/vcr.rb
brightbox-cli-2.10.0 spec/support/vcr.rb
brightbox-cli-2.9.3 spec/support/vcr.rb
brightbox-cli-2.9.2 spec/support/vcr.rb
brightbox-cli-2.9.1 spec/support/vcr.rb
brightbox-cli-2.9.0 spec/support/vcr.rb
brightbox-cli-2.8.2 spec/support/vcr.rb
brightbox-cli-2.8.1 spec/support/vcr.rb
brightbox-cli-2.8.0 spec/support/vcr.rb
brightbox-cli-2.7.1 spec/support/vcr.rb
brightbox-cli-2.7.0 spec/support/vcr.rb
brightbox-cli-2.6.0 spec/support/vcr.rb