Sha256: d779f0fd7afa7304c124e5e87f6494207cc647348189bb30e9465f0b32d44fc2

Contents?: true

Size: 1.84 KB

Versions: 58

Compression:

Stored size: 1.84 KB

Contents

Feature: Allow HTTP connections when no cassette

  Usually, HTTP requests made when no cassette is inserted will [result in an
  error](../cassettes/error-for-http-request-made-when-no-cassette-is-in-use).
  You can set the `allow_http_connections_when_no_cassette` configuration option
  to true to allow requests, if you do not want to use VCR for everything.

  Background:
    Given a file named "vcr_setup.rb" with:
      """ruby
      if ARGV.include?('--with-server')
        $server = start_sinatra_app do
          get('/') { "Hello" }
        end
      end

      require 'vcr'

      VCR.configure do |c|
        c.allow_http_connections_when_no_cassette = true
        c.hook_into :webmock
        c.cassette_library_dir = 'cassettes'
        c.default_cassette_options = {
          :match_requests_on => [:method, :host, :path]
        }
      end
      """
    And the directory "vcr/cassettes" does not exist

  Scenario: Allow HTTP connections when no cassette
    Given a file named "no_cassette.rb" with:
      """ruby
      require 'vcr_setup.rb'

      puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
      """
    When I run `ruby no_cassette.rb --with-server`
    Then the output should contain "Response: Hello"

  Scenario: Cassettes record and replay as normal
    Given a file named "record_replay_cassette.rb" with:
      """ruby
      require 'vcr_setup.rb'

      VCR.use_cassette('localhost') do
        puts "Response: " + Net::HTTP.get_response('localhost', '/', $server ? $server.port : 0).body
      end
      """
    When I run `ruby record_replay_cassette.rb --with-server`
    Then the output should contain "Response: Hello"
    And the file "cassettes/localhost.yml" should contain "Hello"

    When I run `ruby record_replay_cassette.rb`
    Then the output should contain "Response: Hello"

Version data entries

58 entries across 58 versions & 7 rubygems

Version Path
cloudsmith-api-1.42.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-1.33.7 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-1.30.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.57.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.51.38 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.51.37 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.51.34 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.51.22 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/features/configuration/allow_http_connections_when_no_cassette.feature