vcr 3.0.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vcr.rb +18 -1
- data/lib/vcr/cassette.rb +11 -3
- data/lib/vcr/cassette/persisters/file_system.rb +1 -1
- data/lib/vcr/configuration.rb +3 -5
- data/lib/vcr/deprecations.rb +0 -62
- data/lib/vcr/errors.rb +16 -0
- data/lib/vcr/library_hooks/typhoeus.rb +37 -8
- data/lib/vcr/middleware/faraday.rb +5 -1
- data/lib/vcr/structs.rb +1 -1
- data/lib/vcr/util/hooks.rb +1 -0
- data/lib/vcr/version.rb +1 -1
- metadata +9 -249
- data/features/CHANGELOG.md +0 -710
- data/features/CONTRIBUTING.md +0 -26
- data/features/LICENSE.md +0 -20
- data/features/README.md +0 -339
- data/features/Upgrade.md +0 -289
- data/features/about_these_examples.md +0 -18
- data/features/cassettes/allow_unused_http_interactions.feature +0 -100
- data/features/cassettes/automatic_re_recording.feature +0 -72
- data/features/cassettes/decompress.feature +0 -74
- data/features/cassettes/dynamic_erb.feature +0 -100
- data/features/cassettes/exclusive.feature +0 -126
- data/features/cassettes/format.feature +0 -411
- data/features/cassettes/freezing_time.feature +0 -68
- data/features/cassettes/naming.feature +0 -28
- data/features/cassettes/no_cassette.feature +0 -152
- data/features/cassettes/update_content_length_header.feature +0 -112
- data/features/configuration/allow_http_connections_when_no_cassette.feature +0 -55
- data/features/configuration/cassette_library_dir.feature +0 -31
- data/features/configuration/debug_logging.feature +0 -58
- data/features/configuration/default_cassette_options.feature +0 -100
- data/features/configuration/filter_sensitive_data.feature +0 -153
- data/features/configuration/hook_into.feature +0 -172
- data/features/configuration/ignore_request.feature +0 -192
- data/features/configuration/preserve_exact_body_bytes.feature +0 -108
- data/features/configuration/query_parser.feature +0 -84
- data/features/configuration/uri_parser.feature +0 -93
- data/features/getting_started.md +0 -82
- data/features/hooks/after_http_request.feature +0 -58
- data/features/hooks/around_http_request.feature +0 -57
- data/features/hooks/before_http_request.feature +0 -63
- data/features/hooks/before_playback.feature +0 -184
- data/features/hooks/before_record.feature +0 -172
- data/features/http_libraries/em_http_request.feature +0 -250
- data/features/http_libraries/net_http.feature +0 -179
- data/features/middleware/faraday.feature +0 -56
- data/features/middleware/rack.feature +0 -92
- data/features/record_modes/all.feature +0 -82
- data/features/record_modes/new_episodes.feature +0 -79
- data/features/record_modes/none.feature +0 -72
- data/features/record_modes/once.feature +0 -95
- data/features/request_matching/README.md +0 -30
- data/features/request_matching/body.feature +0 -91
- data/features/request_matching/body_as_json.feature +0 -90
- data/features/request_matching/custom_matcher.feature +0 -135
- data/features/request_matching/headers.feature +0 -85
- data/features/request_matching/host.feature +0 -95
- data/features/request_matching/identical_request_sequence.feature +0 -89
- data/features/request_matching/method.feature +0 -96
- data/features/request_matching/path.feature +0 -96
- data/features/request_matching/playback_repeats.feature +0 -98
- data/features/request_matching/query.feature +0 -97
- data/features/request_matching/uri.feature +0 -94
- data/features/request_matching/uri_without_param.feature +0 -101
- data/features/step_definitions/cli_steps.rb +0 -199
- data/features/support/env.rb +0 -46
- data/features/support/http_lib_filters.rb +0 -46
- data/features/test_frameworks/cucumber.feature +0 -211
- data/features/test_frameworks/rspec_macro.feature +0 -81
- data/features/test_frameworks/rspec_metadata.feature +0 -150
- data/features/test_frameworks/test_unit.feature +0 -49
- data/lib/vcr/extensions/net_http_response.rb +0 -36
- data/lib/vcr/library_hooks/fakeweb.rb +0 -197
- data/spec/acceptance/concurrency_spec.rb +0 -51
- data/spec/acceptance/threading_spec.rb +0 -34
- data/spec/fixtures/cassette_spec/1_x_cassette.yml +0 -110
- data/spec/fixtures/cassette_spec/empty.yml +0 -0
- data/spec/fixtures/cassette_spec/example.yml +0 -111
- data/spec/fixtures/cassette_spec/with_localhost_requests.yml +0 -111
- data/spec/fixtures/fake_example_responses.yml +0 -110
- data/spec/fixtures/match_requests_on.yml +0 -187
- data/spec/lib/vcr/cassette/erb_renderer_spec.rb +0 -53
- data/spec/lib/vcr/cassette/http_interaction_list_spec.rb +0 -295
- data/spec/lib/vcr/cassette/migrator_spec.rb +0 -196
- data/spec/lib/vcr/cassette/persisters/file_system_spec.rb +0 -75
- data/spec/lib/vcr/cassette/persisters_spec.rb +0 -39
- data/spec/lib/vcr/cassette/serializers_spec.rb +0 -182
- data/spec/lib/vcr/cassette_spec.rb +0 -618
- data/spec/lib/vcr/configuration_spec.rb +0 -326
- data/spec/lib/vcr/deprecations_spec.rb +0 -85
- data/spec/lib/vcr/errors_spec.rb +0 -178
- data/spec/lib/vcr/extensions/net_http_response_spec.rb +0 -86
- data/spec/lib/vcr/library_hooks/excon_spec.rb +0 -104
- data/spec/lib/vcr/library_hooks/fakeweb_spec.rb +0 -169
- data/spec/lib/vcr/library_hooks/faraday_spec.rb +0 -68
- data/spec/lib/vcr/library_hooks/typhoeus_0.4_spec.rb +0 -36
- data/spec/lib/vcr/library_hooks/typhoeus_spec.rb +0 -162
- data/spec/lib/vcr/library_hooks/webmock_spec.rb +0 -117
- data/spec/lib/vcr/library_hooks_spec.rb +0 -51
- data/spec/lib/vcr/middleware/faraday_spec.rb +0 -181
- data/spec/lib/vcr/middleware/rack_spec.rb +0 -115
- data/spec/lib/vcr/request_ignorer_spec.rb +0 -70
- data/spec/lib/vcr/request_matcher_registry_spec.rb +0 -345
- data/spec/lib/vcr/structs_spec.rb +0 -732
- data/spec/lib/vcr/test_frameworks/cucumber_spec.rb +0 -107
- data/spec/lib/vcr/test_frameworks/rspec_spec.rb +0 -94
- data/spec/lib/vcr/util/hooks_spec.rb +0 -158
- data/spec/lib/vcr/util/internet_connection_spec.rb +0 -37
- data/spec/lib/vcr/util/version_checker_spec.rb +0 -31
- data/spec/lib/vcr/version_spec.rb +0 -27
- data/spec/lib/vcr_spec.rb +0 -354
- data/spec/monkey_patches.rb +0 -186
- data/spec/spec_helper.rb +0 -63
- data/spec/support/configuration_stubbing.rb +0 -8
- data/spec/support/cucumber_helpers.rb +0 -39
- data/spec/support/fixnum_extension.rb +0 -10
- data/spec/support/http_library_adapters.rb +0 -289
- data/spec/support/limited_uri.rb +0 -21
- data/spec/support/ruby_interpreter.rb +0 -7
- data/spec/support/shared_example_groups/excon.rb +0 -63
- data/spec/support/shared_example_groups/hook_into_http_library.rb +0 -594
- data/spec/support/shared_example_groups/request_hooks.rb +0 -59
- data/spec/support/sinatra_app.rb +0 -86
- data/spec/support/vcr_localhost_server.rb +0 -76
- data/spec/support/vcr_stub_helpers.rb +0 -17
| @@ -1,107 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe VCR::CucumberTags do
         | 
| 4 | 
            -
              subject { described_class.new(self) }
         | 
| 5 | 
            -
              let(:before_blocks_for_tags) { {} }
         | 
| 6 | 
            -
              let(:after_blocks_for_tags) { {} }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              def scenario(name)
         | 
| 9 | 
            -
                double(:name => name, :feature => double(:name => "My feature name\nThe preamble text is not included"), :failed? => false)
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              let(:current_scenario) { scenario "My scenario name\nThe preamble text is not included" }
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              # define our own Before/After so we can test this in isolation from cucumber's implementation.
         | 
| 15 | 
            -
              def Before(tag, &block)
         | 
| 16 | 
            -
                before_blocks_for_tags[tag.sub('@', '')] = block
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              def After(tag, &block)
         | 
| 20 | 
            -
                after_blocks_for_tags[tag.sub('@', '')] = block
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              def test_tag(cassette_attribute, tag, expected_value, scenario=current_scenario)
         | 
| 24 | 
            -
                expect(VCR.current_cassette).to be_nil
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                before_blocks_for_tags[tag].call(scenario)
         | 
| 27 | 
            -
                expect(VCR.current_cassette.send(cassette_attribute)).to eq(expected_value)
         | 
| 28 | 
            -
                after_blocks_for_tags[tag].call(scenario)
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                expect(VCR.current_cassette).to be_nil
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              %w(tags tag).each do |tag_method|
         | 
| 34 | 
            -
                describe "##{tag_method}" do
         | 
| 35 | 
            -
                  it "creates a cucumber Around hook for each given tag so that the scenario runs with the cassette inserted" do
         | 
| 36 | 
            -
                    subject.send(tag_method, 'tag1', 'tag2')
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                    test_tag(:name, 'tag1', 'cucumber_tags/tag1')
         | 
| 39 | 
            -
                    test_tag(:name, 'tag2', 'cucumber_tags/tag2')
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  it "works with tags that start with an @" do
         | 
| 43 | 
            -
                    subject.send(tag_method, '@tag1', '@tag2')
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                    test_tag(:name, 'tag1', 'cucumber_tags/tag1')
         | 
| 46 | 
            -
                    test_tag(:name, 'tag2', 'cucumber_tags/tag2')
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                  it "passes along the given options to the cassette" do
         | 
| 50 | 
            -
                    subject.send(tag_method, 'tag1', :record => :none)
         | 
| 51 | 
            -
                    subject.send(tag_method, 'tag2', :record => :new_episodes)
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                    test_tag(:record_mode, 'tag1', :none)
         | 
| 54 | 
            -
                    test_tag(:record_mode, 'tag2', :new_episodes)
         | 
| 55 | 
            -
                  end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  context 'with :use_scenario_name as an option' do
         | 
| 58 | 
            -
                    it "uses the scenario's name as the cassette name" do
         | 
| 59 | 
            -
                      subject.send(tag_method, 'tag1', :use_scenario_name => true)
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                      test_tag(:name, 'tag1', 'My feature name/My scenario name')
         | 
| 62 | 
            -
                    end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    it "makes a unique name for each element of scenario outline" do
         | 
| 65 | 
            -
                      subject.send(tag_method, 'tag1', :use_scenario_name => true)
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                      scenario_with_outline = double(:name => "My row name", :failed? => false,
         | 
| 68 | 
            -
                                                   :scenario_outline => double(:feature => double(:name => "My feature name\nThe preamble text is not included"),
         | 
| 69 | 
            -
                                                                             :name => "My scenario outline name"))
         | 
| 70 | 
            -
                      test_tag(:name, 'tag1', 'My feature name/My scenario outline name/My row name', scenario_with_outline)
         | 
| 71 | 
            -
                    end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                    it 'does not pass :use_scenario_name along the given options to the cassette' do
         | 
| 74 | 
            -
                      subject.send(tag_method, 'tag1', :use_scenario_name => true)
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                      expect(VCR::Cassette).to receive(:new).with(anything, hash_not_including(:use_scenario_name))
         | 
| 77 | 
            -
                      before_blocks_for_tags['tag1'].call(current_scenario)
         | 
| 78 | 
            -
                    end
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                    it 'does not modify the options passed to the cassette' do
         | 
| 81 | 
            -
                      original_options = { :use_scenario_name => true, :record => :none }
         | 
| 82 | 
            -
                      subject.send(tag_method, 'tag1', original_options)
         | 
| 83 | 
            -
                      before_blocks_for_tags['tag1'].call(current_scenario)
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                      expect(original_options.size).to eq(2)
         | 
| 86 | 
            -
                      expect(original_options[:use_scenario_name]).to eq(true)
         | 
| 87 | 
            -
                      expect(original_options[:record]).to eq(:none)
         | 
| 88 | 
            -
                    end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                    it "works properly when multiple scenarios use the tag" do
         | 
| 91 | 
            -
                      subject.send(tag_method, 'tag1', :use_scenario_name => true)
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                      test_tag(:name, 'tag1', 'My feature name/Foo', scenario("Foo"))
         | 
| 94 | 
            -
                      test_tag(:name, 'tag1', 'My feature name/Bar', scenario("Bar"))
         | 
| 95 | 
            -
                    end
         | 
| 96 | 
            -
                  end
         | 
| 97 | 
            -
                end
         | 
| 98 | 
            -
              end
         | 
| 99 | 
            -
             | 
| 100 | 
            -
              describe '.tags' do
         | 
| 101 | 
            -
                it 'returns the list of cucumber tags' do
         | 
| 102 | 
            -
                  subject.tags 'tag1', 'tag2'
         | 
| 103 | 
            -
                  subject.tags 'tag3', 'tag4'
         | 
| 104 | 
            -
                  expect(described_class.tags[-4, 4]).to eq(%w(@tag1 @tag2 @tag3 @tag4))
         | 
| 105 | 
            -
                end
         | 
| 106 | 
            -
              end
         | 
| 107 | 
            -
            end
         | 
| @@ -1,94 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            VCR.configuration.configure_rspec_metadata!
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            describe VCR::RSpec::Metadata, :skip_vcr_reset do
         | 
| 6 | 
            -
              before(:all) { VCR.reset! }
         | 
| 7 | 
            -
              after(:each) { VCR.reset! }
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              context 'an example group', :vcr do
         | 
| 10 | 
            -
                context 'with a nested example group' do
         | 
| 11 | 
            -
                  it 'uses a cassette for any examples' do
         | 
| 12 | 
            -
                    expect(VCR.current_cassette.name.split('/')).to eq([
         | 
| 13 | 
            -
                      'VCR::RSpec::Metadata',
         | 
| 14 | 
            -
                      'an example group',
         | 
| 15 | 
            -
                      'with a nested example group',
         | 
| 16 | 
            -
                      'uses a cassette for any examples'
         | 
| 17 | 
            -
                    ])
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                context 'when the spec has no description' do
         | 
| 22 | 
            -
                  it do
         | 
| 23 | 
            -
                    expect(VCR.current_cassette.name.split('/')).to eq([
         | 
| 24 | 
            -
                      'VCR::RSpec::Metadata',
         | 
| 25 | 
            -
                      'an example group',
         | 
| 26 | 
            -
                      'when the spec has no description',
         | 
| 27 | 
            -
                      '1:1:2:1'
         | 
| 28 | 
            -
                    ])
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              context 'with the cassette name overridden at the example group level', :vcr => { :cassette_name => 'foo' } do
         | 
| 34 | 
            -
                it 'overrides the cassette name for an example' do
         | 
| 35 | 
            -
                  expect(VCR.current_cassette.name).to eq('foo')
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                it 'overrides the cassette name for another example' do
         | 
| 39 | 
            -
                  expect(VCR.current_cassette.name).to eq('foo')
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
              it 'allows the cassette name to be overriden', :vcr => { :cassette_name => 'foo' } do
         | 
| 44 | 
            -
                expect(VCR.current_cassette.name).to eq('foo')
         | 
| 45 | 
            -
              end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
              it 'allows the cassette options to be set', :vcr => { :match_requests_on => [:method] } do
         | 
| 48 | 
            -
                expect(VCR.current_cassette.match_requests_on).to eq([:method])
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
            end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            describe VCR::RSpec::Macros do
         | 
| 53 | 
            -
              extend described_class
         | 
| 54 | 
            -
             | 
| 55 | 
            -
              describe '#use_vcr_cassette' do
         | 
| 56 | 
            -
                def self.perform_test(context_name, expected_cassette_name, *args, &block)
         | 
| 57 | 
            -
                  context context_name do
         | 
| 58 | 
            -
                    after(:each) do |example|
         | 
| 59 | 
            -
                      if example.metadata[:test_ejection]
         | 
| 60 | 
            -
                        expect(VCR.current_cassette).to be_nil
         | 
| 61 | 
            -
                      end
         | 
| 62 | 
            -
                    end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    use_vcr_cassette(*args)
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                    it 'ejects the cassette in an after hook', :test_ejection do
         | 
| 67 | 
            -
                      expect(VCR.current_cassette).to be_a(VCR::Cassette)
         | 
| 68 | 
            -
                    end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                    it "creates a cassette named '#{expected_cassette_name}" do
         | 
| 71 | 
            -
                      expect(VCR.current_cassette.name).to eq(expected_cassette_name)
         | 
| 72 | 
            -
                    end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    module_eval(&block) if block
         | 
| 75 | 
            -
                  end
         | 
| 76 | 
            -
                end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                perform_test 'when called with an explicit name', 'explicit_name', 'explicit_name'
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                perform_test 'when called with an explicit name and some options', 'explicit_name', 'explicit_name', :match_requests_on => [:method, :host] do
         | 
| 81 | 
            -
                  it 'uses the provided cassette options' do
         | 
| 82 | 
            -
                    expect(VCR.current_cassette.match_requests_on).to eq([:method, :host])
         | 
| 83 | 
            -
                  end
         | 
| 84 | 
            -
                end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                perform_test 'when called with nothing', 'VCR::RSpec::Macros/#use_vcr_cassette/when called with nothing'
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                perform_test 'when called with some options', 'VCR::RSpec::Macros/#use_vcr_cassette/when called with some options', :match_requests_on => [:method, :host] do
         | 
| 89 | 
            -
                  it 'uses the provided cassette options' do
         | 
| 90 | 
            -
                    expect(VCR.current_cassette.match_requests_on).to eq([:method, :host])
         | 
| 91 | 
            -
                  end
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
            end
         | 
| @@ -1,158 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe VCR::Hooks::FilteredHook do
         | 
| 4 | 
            -
              describe "#conditionally_invoke" do
         | 
| 5 | 
            -
                it 'invokes the hook' do
         | 
| 6 | 
            -
                  called = false
         | 
| 7 | 
            -
                  subject.hook = lambda { called = true }
         | 
| 8 | 
            -
                  subject.conditionally_invoke
         | 
| 9 | 
            -
                  expect(called).to be true
         | 
| 10 | 
            -
                end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                it 'forwards the given arguments to the hook' do
         | 
| 13 | 
            -
                  args = nil
         | 
| 14 | 
            -
                  subject.hook = lambda { |a, b| args = [a, b] }
         | 
| 15 | 
            -
                  subject.conditionally_invoke(3, 5)
         | 
| 16 | 
            -
                  expect(args).to eq([3, 5])
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                it 'forwards only as many arguments as the hook block accepts' do
         | 
| 20 | 
            -
                  args = nil
         | 
| 21 | 
            -
                  subject.hook = lambda { |a| args = [a] }
         | 
| 22 | 
            -
                  subject.conditionally_invoke(3, 5)
         | 
| 23 | 
            -
                  expect(args).to eq([3])
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                it 'does not invoke the hook if all of the filters return false' do
         | 
| 27 | 
            -
                  called = false
         | 
| 28 | 
            -
                  subject.hook = lambda { called = true }
         | 
| 29 | 
            -
                  subject.filters = lambda { false }
         | 
| 30 | 
            -
                  subject.conditionally_invoke
         | 
| 31 | 
            -
                  expect(called).to be false
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                it 'does not invoke the hook if any of the filters returns false' do
         | 
| 35 | 
            -
                  called = false
         | 
| 36 | 
            -
                  subject.hook = lambda { called = true }
         | 
| 37 | 
            -
                  subject.filters = [lambda { false }, lambda { true }]
         | 
| 38 | 
            -
                  subject.conditionally_invoke
         | 
| 39 | 
            -
                  expect(called).to be false
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                it 'forwards arguments to the filters' do
         | 
| 43 | 
            -
                  filter_args = nil
         | 
| 44 | 
            -
                  subject.filters = lambda { |a, b| filter_args = [a, b]; false }
         | 
| 45 | 
            -
                  subject.conditionally_invoke(3, 5)
         | 
| 46 | 
            -
                  expect(filter_args).to eq([3, 5])
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                it 'handles splat args properly' do
         | 
| 50 | 
            -
                  filter_args = nil
         | 
| 51 | 
            -
                  subject.filters = lambda { |*args| filter_args = args; false }
         | 
| 52 | 
            -
                  subject.conditionally_invoke(3, 5)
         | 
| 53 | 
            -
                  expect(filter_args).to eq([3, 5])
         | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                it 'forwards only as many arguments as the filter blocks accept' do
         | 
| 57 | 
            -
                  args1 = args2 = nil
         | 
| 58 | 
            -
                  subject.filters = [
         | 
| 59 | 
            -
                    lambda { |a| args1 = [a]; true },
         | 
| 60 | 
            -
                    lambda { |a, b| args2 = [a, b]; false }
         | 
| 61 | 
            -
                  ]
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                  subject.conditionally_invoke(3, 5)
         | 
| 64 | 
            -
                  expect(args1).to eq([3])
         | 
| 65 | 
            -
                  expect(args2).to eq([3, 5])
         | 
| 66 | 
            -
                end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                it '#to_procs the filter objects' do
         | 
| 69 | 
            -
                  filter_called = false
         | 
| 70 | 
            -
                  subject.hook = lambda { }
         | 
| 71 | 
            -
                  subject.filters = [double(:to_proc => lambda { filter_called = true })]
         | 
| 72 | 
            -
                  subject.conditionally_invoke
         | 
| 73 | 
            -
                  expect(filter_called).to be true
         | 
| 74 | 
            -
                end
         | 
| 75 | 
            -
              end
         | 
| 76 | 
            -
            end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            describe VCR::Hooks do
         | 
| 79 | 
            -
              let(:hooks_class) { Class.new { include VCR::Hooks } }
         | 
| 80 | 
            -
             | 
| 81 | 
            -
              subject { hooks_class.new }
         | 
| 82 | 
            -
              let(:invocations) { [] }
         | 
| 83 | 
            -
             | 
| 84 | 
            -
              before(:each) do
         | 
| 85 | 
            -
                hooks_class.instance_eval do
         | 
| 86 | 
            -
                  define_hook :before_foo
         | 
| 87 | 
            -
                  define_hook :before_bar, :prepend
         | 
| 88 | 
            -
                end
         | 
| 89 | 
            -
              end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
              it 'allows the class to override the hook method and super to the main definition' do
         | 
| 92 | 
            -
                override_called = nil
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                hooks_class.class_eval do
         | 
| 95 | 
            -
                  define_method :before_foo do |&block|
         | 
| 96 | 
            -
                    override_called = true
         | 
| 97 | 
            -
                    super(&block)
         | 
| 98 | 
            -
                  end
         | 
| 99 | 
            -
                end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                subject.before_foo { }
         | 
| 102 | 
            -
                expect(override_called).to be true
         | 
| 103 | 
            -
              end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
              describe '#clear_hooks' do
         | 
| 106 | 
            -
                it 'clears all hooks' do
         | 
| 107 | 
            -
                  subject.before_foo { invocations << :callback }
         | 
| 108 | 
            -
                  subject.clear_hooks
         | 
| 109 | 
            -
                  subject.invoke_hook(:before_foo)
         | 
| 110 | 
            -
                  expect(invocations).to be_empty
         | 
| 111 | 
            -
                end
         | 
| 112 | 
            -
              end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
              describe '#invoke_hook' do
         | 
| 115 | 
            -
                it 'invokes each of the callbacks' do
         | 
| 116 | 
            -
                  subject.before_foo { invocations << :callback_1 }
         | 
| 117 | 
            -
                  subject.before_foo { invocations << :callback_2 }
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                  expect(invocations).to be_empty
         | 
| 120 | 
            -
                  subject.invoke_hook(:before_foo)
         | 
| 121 | 
            -
                  expect(invocations).to eq([:callback_1, :callback_2])
         | 
| 122 | 
            -
                end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                it 'maps the return value of each callback' do
         | 
| 125 | 
            -
                  subject.before_foo { 17 }
         | 
| 126 | 
            -
                  subject.before_foo { 12 }
         | 
| 127 | 
            -
                  expect(subject.invoke_hook(:before_foo)).to eq([17, 12])
         | 
| 128 | 
            -
                end
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                it 'does not invoke any filtered callbacks' do
         | 
| 131 | 
            -
                  subject.before_foo(:real?) { invocations << :blue_callback }
         | 
| 132 | 
            -
                  subject.invoke_hook(:before_foo, double(:real? => false))
         | 
| 133 | 
            -
                  expect(invocations).to be_empty
         | 
| 134 | 
            -
                end
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                it 'invokes them in reverse order if the hook was defined with :prepend' do
         | 
| 137 | 
            -
                  subject.before_bar { 17 }
         | 
| 138 | 
            -
                  subject.before_bar { 12 }
         | 
| 139 | 
            -
                  expect(subject.invoke_hook(:before_bar)).to eq([12, 17])
         | 
| 140 | 
            -
                end
         | 
| 141 | 
            -
              end
         | 
| 142 | 
            -
             | 
| 143 | 
            -
              describe "#has_hooks_for?" do
         | 
| 144 | 
            -
                it 'returns false when given an unrecognized hook name' do
         | 
| 145 | 
            -
                  expect(subject).not_to have_hooks_for(:abcd)
         | 
| 146 | 
            -
                end
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                it 'returns false when given the name of a defined hook that has no registered callbacks' do
         | 
| 149 | 
            -
                  expect(subject).not_to have_hooks_for(:before_foo)
         | 
| 150 | 
            -
                end
         | 
| 151 | 
            -
             | 
| 152 | 
            -
                it 'returns true when given the name of a defined hook that has registered callbacks' do
         | 
| 153 | 
            -
                  subject.before_foo { }
         | 
| 154 | 
            -
                  expect(subject).to have_hooks_for(:before_foo)
         | 
| 155 | 
            -
                end
         | 
| 156 | 
            -
              end
         | 
| 157 | 
            -
            end
         | 
| 158 | 
            -
             | 
| @@ -1,37 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe VCR::InternetConnection do
         | 
| 4 | 
            -
              describe '.available?' do
         | 
| 5 | 
            -
                before(:each) do
         | 
| 6 | 
            -
                  described_class.send(:remove_instance_variable, :@available) if described_class.instance_variable_defined?(:@available)
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def stub_pingecho_with(value)
         | 
| 10 | 
            -
                  allow(VCR::Ping).to receive(:pingecho).with("example.com", anything, anything).and_return(value)
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                context 'when pinging example.com succeeds' do
         | 
| 14 | 
            -
                  it 'returns true' do
         | 
| 15 | 
            -
                    stub_pingecho_with(true)
         | 
| 16 | 
            -
                    expect(described_class).to be_available
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  it 'memoizes the value so no extra pings are made' do
         | 
| 20 | 
            -
                    expect(VCR::Ping).to receive(:pingecho).once.and_return(true)
         | 
| 21 | 
            -
                    3.times { described_class.available? }
         | 
| 22 | 
            -
                  end
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                context 'when pinging example.com fails' do
         | 
| 26 | 
            -
                  it 'returns false' do
         | 
| 27 | 
            -
                    stub_pingecho_with(false)
         | 
| 28 | 
            -
                    expect(described_class).not_to be_available
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                  it 'memoizes the value so no extra pings are made' do
         | 
| 32 | 
            -
                    expect(VCR::Ping).to receive(:pingecho).once.and_return(false)
         | 
| 33 | 
            -
                    3.times { described_class.available? }
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
              end
         | 
| 37 | 
            -
            end
         | 
| @@ -1,31 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module VCR
         | 
| 4 | 
            -
              describe VersionChecker do
         | 
| 5 | 
            -
                it 'raises an error if the major version is too low' do
         | 
| 6 | 
            -
                  checker = VersionChecker.new('foo', '0.7.3', '1.0.0')
         | 
| 7 | 
            -
                  expect { checker.check_version! }.to raise_error(Errors::LibraryVersionTooLowError)
         | 
| 8 | 
            -
                end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                it 'raises an error if the minor version is too low' do
         | 
| 11 | 
            -
                  checker = VersionChecker.new('foo', '1.0.99', '1.1.3')
         | 
| 12 | 
            -
                  expect { checker.check_version! }.to raise_error(Errors::LibraryVersionTooLowError)
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                it 'raises an error if the patch version is too low' do
         | 
| 16 | 
            -
                  checker = VersionChecker.new('foo', '1.0.8', '1.0.10')
         | 
| 17 | 
            -
                  expect { checker.check_version! }.to raise_error(Errors::LibraryVersionTooLowError)
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                it 'does not raise an error when the version is equal' do
         | 
| 21 | 
            -
                  checker = VersionChecker.new('foo', '1.0.0', '1.0.0')
         | 
| 22 | 
            -
                  expect { checker.check_version! }.not_to raise_error
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                it 'does not raise an error when the version is higher' do
         | 
| 26 | 
            -
                  checker = VersionChecker.new('foo', '2.0.0', '1.0.0')
         | 
| 27 | 
            -
                  expect { checker.check_version! }.not_to raise_error
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
            end
         | 
| 31 | 
            -
             | 
| @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe "VCR.version" do
         | 
| 4 | 
            -
              subject { VCR.version }
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              it { should =~ /\A\d+\.\d+\.\d+(\.\w+)?\z/ }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              describe '#parts' do
         | 
| 9 | 
            -
                subject { super().parts }
         | 
| 10 | 
            -
                it { should be_instance_of(Array)  }
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              describe '#major' do
         | 
| 14 | 
            -
                subject { super().major }
         | 
| 15 | 
            -
                it { should be_instance_of(Fixnum) }
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              describe '#minor' do
         | 
| 19 | 
            -
                subject { super().minor }
         | 
| 20 | 
            -
                it { should be_instance_of(Fixnum) }
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              describe '#patch' do
         | 
| 24 | 
            -
                subject { super().patch }
         | 
| 25 | 
            -
                it { should be_instance_of(Fixnum) }
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
            end
         |