Sha256: 9fdce0849f71e887a386c41a2e079711f1cbd0b0b500b3933e687b78699dd3e5

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

require "spec_helper"

describe ShippingEasy::Http::FaradayAdapter do

  let(:http_method) { "post" }
  let(:params) { { "page" => 1 } }
  let(:base_url) { "https://www.test.com" }
  let(:uri) { "/api/orders" }
  let(:body) { { order_number: "1234" }.to_json }

  let(:request) do
    double("request",
            http_method: http_method,
            params: params,
            base_url: base_url,
            uri: uri,
            body: body)
  end

  subject { ShippingEasy::Http::FaradayAdapter.new(request) }

  [:http_method, :params, :base_url, :uri, :body].each do |m|
    it "delegates #{m} to request" do
      subject.send(m).should == request.send(m)
    end
  end

  describe "#connect!" do
    it "calls the correct http method as specified by the request" do
      subject.stub(:post)
      subject.should_receive(:post).once
      subject.connect!
    end
  end

  describe "#connection" do
    it "instantiates a faraday connection" do
      subject.connection.should be_a(Faraday::Connection)
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipping_easy-0.6.1 spec/http/faraday_adapter_spec.rb
shipping_easy-0.6.0 spec/http/faraday_adapter_spec.rb
shipping_easy-0.5.1 spec/http/faraday_adapter_spec.rb
shipping_easy-0.5.0 spec/http/faraday_adapter_spec.rb
shipping_easy-0.3.2 spec/http/faraday_adapter_spec.rb
shipping_easy-0.3.1 spec/http/faraday_adapter_spec.rb
shipping_easy-0.3.0 spec/http/faraday_adapter_spec.rb
shipping_easy-0.2.2 spec/http/faraday_adapter_spec.rb
shipping_easy-0.2.1 spec/http/faraday_adapter_spec.rb
shipping_easy-0.2.0 spec/http/faraday_adapter_spec.rb