Sha256: c85e25cce0e6807b4f1caaf647542abcb9d141c171668186b1b6526ba98a694c

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"
require "httpi/adapter"

describe HTTPI::Adapter do
  let(:adapter) { HTTPI::Adapter }

  describe ".use" do
    around do |example|
      adapter.use = nil
      example.run
      adapter.use = nil
    end

    it "sets the adapter to use" do
      adapter.use.should_not == :net_http

      adapter.use = :net_http
      adapter.use.should == :net_http
    end

    it "defaults to use the HTTPClient adapter" do
      adapter.use.should == :httpclient
    end

    it "loads the adapter's client library" do
      adapter.expects(:require).with("httpclient")
      adapter.use = :httpclient
    end

    it "raises an ArgumentError in case of an invalid adapter" do
      expect { adapter.use = :unknown }.to raise_error(ArgumentError)
    end
  end

  describe ".load" do
    context "called with a valid adapter" do
      it "returns the adapter's name and class" do
        adapter.load(:curb).should == [:curb, HTTPI::Adapter::Curb]
      end
    end

    context "called with nil" do
      it "returns the default adapter's name and class" do
        adapter.load(nil).should == [:httpclient, HTTPI::Adapter::HTTPClient]
      end
    end

    context "called with an invalid adapter" do
      it "raises an ArgumentError" do
        expect { adapter.use = :unknown }.to raise_error(ArgumentError)
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/httpi-0.9.7/spec/httpi/adapter_spec.rb
httpi-1.1.1 spec/httpi/adapter_spec.rb
httpi-1.1.0 spec/httpi/adapter_spec.rb
httpi-1.0.0 spec/httpi/adapter_spec.rb
httpi-0.9.7 spec/httpi/adapter_spec.rb
httpi-0.9.6 spec/httpi/adapter_spec.rb
regenersis-httpi-0.9.6 spec/httpi/adapter_spec.rb
httpi-ntlm-0.9.6 spec/httpi/adapter_spec.rb
httpi-0.9.5 spec/httpi/adapter_spec.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/httpi-0.9.4/spec/httpi/adapter_spec.rb
httpi-0.9.4 spec/httpi/adapter_spec.rb