File: rspec_spec.rb

package info (click to toggle)
ruby-vcr 6.0.0%2Breally5.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,320 kB
  • sloc: ruby: 8,456; sh: 177; makefile: 7
file content (50 lines) | stat: -rw-r--r-- 1,514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'spec_helper'

VCR.configuration.configure_rspec_metadata!

describe VCR::RSpec::Metadata, :skip_vcr_reset do
  before(:all) { VCR.reset! }
  after(:each) { VCR.reset! }

  context 'an example group', :vcr do
    context 'with a nested example group' do
      it 'uses a cassette for any examples' do
        expect(VCR.current_cassette.name.split('/')).to eq([
          'VCR::RSpec::Metadata',
          'an example group',
          'with a nested example group',
          'uses a cassette for any examples'
        ])
      end
    end

    context 'when the spec has no description' do
      it do
        expect(VCR.current_cassette.name.split('/')).to eq([
          'VCR::RSpec::Metadata',
          'an example group',
          'when the spec has no description',
          '1:1:2:1'
        ])
      end
    end
  end

  context 'with the cassette name overridden at the example group level', :vcr => { :cassette_name => 'foo' } do
    it 'overrides the cassette name for an example' do
      expect(VCR.current_cassette.name).to eq('foo')
    end

    it 'overrides the cassette name for another example' do
      expect(VCR.current_cassette.name).to eq('foo')
    end
  end

  it 'allows the cassette name to be overriden', :vcr => { :cassette_name => 'foo' } do
    expect(VCR.current_cassette.name).to eq('foo')
  end

  it 'allows the cassette options to be set', :vcr => { :match_requests_on => [:method] } do
    expect(VCR.current_cassette.match_requests_on).to eq([:method])
  end
end