Sha256: 1799f9719ad0ecbd51d646f4f49e33878a4fd9da05acf2ec1ee31243a60a6369

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 KB

Contents

Feature: ignore_hosts

  The `ignore_hosts` configuration option can be used to prevent VCR
  from having any affect on requests to particular hosts.
  Requests to ignored hosts will not be recorded and will always be
  allowed, regardless of the record mode, and even outside of a
  `VCR.use_cassette` block.

  If you only want to ignore localhost (and its various aliases) you
  may want to use the `ignore_localhost` option instead.

  Background:
    Given a file named "sinatra_app.rb" with:
      """ruby
      response_count = 0
      start_sinatra_app(:port => 7777) do
        get('/') { "Response #{response_count += 1}" }
      end
      """

  Scenario Outline: ignored host requests are not recorded and are always allowed
    Given a file named "ignore_hosts.rb" with:
      """ruby
      include_http_adapter_for("<http_lib>")
      require 'sinatra_app.rb'

      require 'vcr'

      VCR.configure do |c|
        c.ignore_hosts '127.0.0.1', 'localhost'
        c.cassette_library_dir = 'cassettes'
        <configuration>
      end

      VCR.use_cassette('example') do
        puts response_body_for(:get, "http://localhost:7777/")
      end

      puts response_body_for(:get, "http://localhost:7777/")
      """
    When I run `ruby ignore_hosts.rb`
    Then it should pass with:
      """
      Response 1
      Response 2
      """
    And the file "cassettes/example.yml" should not exist

    Examples:
      | configuration         | http_lib              |
      | c.hook_into :fakeweb  | net/http              |
      | c.hook_into :webmock  | net/http              |
      | c.hook_into :webmock  | httpclient            |
      | c.hook_into :webmock  | curb                  |
      | c.hook_into :webmock  | patron                |
      | c.hook_into :webmock  | em-http-request       |
      | c.hook_into :webmock  | typhoeus              |
      | c.hook_into :typhoeus | typhoeus              |
      | c.hook_into :excon    | excon                 |
      |                       | faraday (w/ net_http) |

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vcr-2.0.0.beta2 features/configuration/ignore_hosts.feature
vcr-2.0.0.beta1 features/configuration/ignore_hosts.feature