Module: VCR::RSpec::Macros

Defined in:
lib/vcr/deprecations.rb

Overview

Contains macro methods to assist with VCR usage. These methods are intended to be used directly in an RSpec example group. To make these available in your RSpec example groups, extend the module in an individual example group, or configure RSpec to extend the module in all example groups.

Examples:

RSpec.configure do |c|
  c.extend VCR::RSpec::Macros
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



59
60
61
# File 'lib/vcr/deprecations.rb', line 59

def self.extended(base)
  Kernel.warn "WARNING: VCR::RSpec::Macros is deprecated. Use RSpec metadata options instead `:vcr => vcr_options`"
end

Instance Method Details

#use_vcr_cassette(*args) ⇒ Object

Deprecated.

Use RSpec metadata options

Sets up a ‘before` and `after` hook that will insert and eject a cassette, respectively.

Examples:

describe "Some API Client" do
  use_vcr_cassette "some_api", :record => :new_episodes
end

Parameters:

  • name ((optional) String)

    the cassette name; it will be inferred by the example group descriptions if not given.

  • options ((optional) Hash)

    the cassette options



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vcr/deprecations.rb', line 75

def use_vcr_cassette(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  name    = args.first || infer_cassette_name

  before(:each) do
    VCR.insert_cassette(name, options)
  end

  after(:each) do
    VCR.eject_cassette
  end
end