Sha256: 86ac375406e4e52b51b957ee1ee87882af1ce16e5e0183f19b54d2afa05800e8

Contents?: true

Size: 1.81 KB

Versions: 6964

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe Typhoeus::Request::BlockConnection do
  let(:base_url) { "localhost:3001" }
  let(:request) { Typhoeus::Request.new(base_url, {:method => :get}) }

  describe "run" do
    context "when blocked" do
      before { request.block_connection = true }

      it "raises" do
        expect{ request.run }.to raise_error(Typhoeus::Errors::NoStub)
      end
    end

    context "when not blocked" do
      before { request.block_connection = false }

      it "doesn't raise" do
        expect{ request.run }.to_not raise_error
      end
    end
  end

  describe "#blocked?" do
    context "when local block_connection" do
      context "when true" do
        before { request.block_connection = true }

        it "returns true" do
          expect(request.blocked?).to be_truthy
        end
      end

      context "when false" do
        before { request.block_connection = false }

        it "returns false" do
          expect(request.blocked?).to be_falsey
        end
      end
    end

    context "when global block_connection" do
      context "when true" do
        before { Typhoeus::Config.block_connection = true }
        after { Typhoeus::Config.block_connection = false }

        it "returns true" do
          expect(request.blocked?).to be_truthy
        end
      end

      context "when false" do
        before { Typhoeus::Config.block_connection = false }

        it "returns false" do
          expect(request.blocked?).to be_falsey
        end
      end
    end

    context "when global and local block_connection" do
      before do
        Typhoeus::Config.block_connection = true
        request.block_connection = false
      end
      after { Typhoeus::Config.block_connection = false }

      it "takes local" do
        expect(request.blocked?).to be_falsey
      end
    end
  end
end

Version data entries

6,964 entries across 6,961 versions & 28 rubygems

Version Path
cybrid_api_organization_ruby-0.8.6 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.5 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.5 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.5 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.4 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.4 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.4 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.3 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.3 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.3 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.2 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.2 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.2 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.1 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.1 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.1 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_bank_ruby-0.8.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_id_ruby-0.8.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.8.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb
cybrid_api_organization_ruby-0.7.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.0/spec/typhoeus/request/block_connection_spec.rb