Sha256: d8d6f67b4459c8e0e9d719d69cdb2f940b9467b0187a184fda16f69462b1fa84

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require "spec_helpers"

describe Wayfarer::Config::Networking do
  let(:env) { {} }
  subject(:network) { Wayfarer::Config::Networking.new(env) }

  describe "#agent" do
    context "by default" do
      it "is :http" do
        expect(network.agent).to be(:http)
      end
    end

    context "with env var set" do
      before { env["WAYFARER_NETWORK_AGENT"] = "ferrum" }

      it "parses the env var" do
        expect(network.agent).to be(:ferrum)
      end
    end
  end

  describe "#pool_size" do
    context "by default" do
      it "is 1" do
        expect(network.pool_size).to be(1)
      end
    end

    context "with env var set" do
      before { env["WAYFARER_NETWORK_POOL_SIZE"] = "42" }

      it "parses the env var" do
        expect(network.pool_size).to be(42)
      end
    end
  end

  describe "#pool_timeout" do
    context "by default" do
      it "is 10" do
        expect(network.pool_timeout).to be(10)
      end
    end

    context "with env var set" do
      before { env["WAYFARER_NETWORK_POOL_SIZE"] = "1337" }

      it "parses the env var" do
        expect(network.pool_size).to be(1337)
      end
    end
  end

  describe "#http_headers" do
    context "by default" do
      it "is {}" do
        expect(network.http_headers).to eq({})
      end
    end

    context "with env var set" do
      before { env["WAYFARER_NETWORK_HTTP_HEADERS"] = "user-agent:foo,authorization:bar" }

      it "parses the env var" do
        expect(network.http_headers).to eq("user-agent": "foo",
                                           authorization: "bar")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wayfarer-0.4.6 spec/config/networking_spec.rb
wayfarer-0.4.5 spec/config/networking_spec.rb
wayfarer-0.4.4 spec/config/networking_spec.rb
wayfarer-0.4.3 spec/config/networking_spec.rb
wayfarer-0.4.2 spec/config/networking_spec.rb