Sha256: 9f48756aba2bb6adda71935dbada8efdab34a91c732564258b20e7b57c3a1a5a

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

describe HttpEventLogger::Event::Headers do

  let(:headers) { HttpEventLogger::Event::Headers.new(provided_headers) }

  context "when a hash is provided" do

    let(:provided_headers) { { "some_key" => "some value", "some_other_key" => "some other value" } }

    describe "#[]" do

      context "and the name provided exactly matches a header name" do

        it "returns the value of the header" do
          expect(headers["some_key"]).to eql("some value")
        end

      end

      context "and the name provided is a case insensitive match for a header name" do

        it "returns the value of the header" do
          expect(headers["Some_Key"]).to eql("some value")
        end

      end

      context "and the the name provided does not match a header name" do

        it "returns nil" do
          expect(headers["does_not_match"]).to eql(nil)
        end

      end

    end

    describe "#to_s" do

      it "returns a string containing all header keys and values" do
        expect(headers.to_s).to eql("some_key: some value, some_other_key: some other value")
      end

    end

  end

  context "when a string is provided" do

    let(:provided_headers) { "some_key some value" }

    describe "#[]" do

      it "returns nil" do
        expect(headers["some_key"]).to eql(nil)
      end

    end

    describe "#to_s" do

      it "returns the string" do
        expect(headers.to_s).to eql(provided_headers)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
http_event_logger-0.1.0.rc2 ./spec/lib/http_event_logger/event/headers_spec.rb