Sha256: 17367cc52dbe5597bad66b194301771588eabc726b29a45db22ec5425a384326

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

RSpec.describe BingAdsRubySdk::HttpClient do
  describe ".post" do
    let(:request) do
      double(:request,
        url: "http://bing_url.com/foo",
        content: "body",
        headers: "headers")
    end
    let(:excon) { double(:excon) }

    before do
      expect(::Excon).to receive(:new).and_return(excon)
      expect(excon).to receive(:post).with(
        path: "/foo",
        body: "body",
        headers: "headers"
      ).and_return(response)
    end

    context "successful request" do
      let(:response) { double(:response, body: "soap xml") }
      it "returns response's body" do
        expect(described_class.post(request)).to eq("soap xml")
      end
    end
  end

  describe ".close_http_connections" do
    let(:connection1) { double("connection1") }
    let(:connection2) { double("connection2") }
    it "closes existing connections" do
      expect(described_class).to receive(:http_connections).and_return({
        "url1" => connection1,
        "url2" => connection2
      })
      expect(connection1).to receive :reset
      expect(connection2).to receive :reset

      described_class.close_http_connections
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bing_ads_ruby_sdk-1.5.0 spec/bing_ads_ruby_sdk/http_client_spec.rb