Sha256: 70a30d26d3e7a157cd5e47ffb94dc13d7c4e8e06e9a7ac52d33e02410e9f7100

Contents?: true

Size: 1.52 KB

Versions: 16

Compression:

Stored size: 1.52 KB

Contents

require 'vcr/library_hooks'

module VCR
  describe LibraryHooks do
    describe '#disabled?' do
      it 'returns false by default for any argument given' do
        subject.disabled?(:foo).should be_false
        subject.disabled?(:bar).should be_false
      end

      context 'when a library hook is exclusively enabled' do
        it 'returns false for the exclusively enabled hook' do
          faraday_disabled = nil

          subject.exclusively_enabled :faraday do
            faraday_disabled = subject.disabled?(:faraday)
          end

          faraday_disabled.should eq(false)
        end

        it 'returns true for every other argument given' do
          foo_disabled = bar_disabled = nil

          subject.exclusively_enabled :faraday do
            foo_disabled = subject.disabled?(:foo)
            bar_disabled = subject.disabled?(:bar)
          end

          foo_disabled.should be_true
          bar_disabled.should be_true
        end
      end
    end

    describe '#exclusively_enabled' do
      it 'restores all hook to being enabled when the block completes' do
        subject.exclusively_enabled(:faraday) { }
        subject.disabled?(:foo).should be_false
        subject.disabled?(:faraday).should be_false
      end

      it 'restores all hooks to being enabled when the block completes, even if there is an error' do
        subject.exclusively_enabled(:faraday) { raise "boom" } rescue
        subject.disabled?(:foo).should be_false
        subject.disabled?(:faraday).should be_false
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
vcr-2.4.0 spec/vcr/library_hooks_spec.rb
vcr-2.3.0 spec/vcr/library_hooks_spec.rb
vcr-2.2.5 spec/vcr/library_hooks_spec.rb
vcr-2.2.4 spec/vcr/library_hooks_spec.rb
vcr-2.2.3 spec/vcr/library_hooks_spec.rb
vcr-2.2.2 spec/vcr/library_hooks_spec.rb
vcr-2.2.1 spec/vcr/library_hooks_spec.rb
vcr-2.2.0 spec/vcr/library_hooks_spec.rb
vcr-2.1.1 spec/vcr/library_hooks_spec.rb
vcr-2.1.0 spec/vcr/library_hooks_spec.rb
vcr-2.0.1 spec/vcr/library_hooks_spec.rb
vcr-2.0.0 spec/vcr/library_hooks_spec.rb
vcr-2.0.0.rc2 spec/vcr/library_hooks_spec.rb
vcr-2.0.0.rc1 spec/vcr/library_hooks_spec.rb
vcr-2.0.0.beta2 spec/vcr/library_hooks_spec.rb
vcr-2.0.0.beta1 spec/vcr/library_hooks_spec.rb