Sha256: a6319599f6840b9b2642152ec06990a4837b80d160d5971e2fe777af11089b18

Contents?: true

Size: 1018 Bytes

Versions: 21

Compression:

Stored size: 1018 Bytes

Contents

require "spec_helper"
require "httpi"

describe HTTPI::Cookie do

  let(:cookie) { HTTPI::Cookie.new("token=choc-choc-chip; Path=/; HttpOnly") }

  describe ".list_from_headers" do
    it "returns a list of cookies from a Hash of headers" do
      headers = { "Set-Cookie" => "token=strawberry; Path=/; HttpOnly" }
      cookies = HTTPI::Cookie.list_from_headers(headers)

      expect(cookies.size).to eq(1)
      expect(cookies.first).to be_a(HTTPI::Cookie)
    end

    it "handles multiple cookies" do
      headers = { "Set-Cookie" => ["user=chucknorris; Path=/; HttpOnly", "token=strawberry; Path=/; HttpOnly"] }
      cookies = HTTPI::Cookie.list_from_headers(headers)
      expect(cookies.size).to eq(2)
    end
  end

  describe "#name" do
    it "returns the name of the cookie" do
      expect(cookie.name).to eq("token")
    end
  end

  describe "#name_and_value" do
    it "returns the name and value of the cookie" do
      expect(cookie.name_and_value).to eq("token=choc-choc-chip")
    end
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
httpi-4.0.3 spec/httpi/cookie_spec.rb
httpi-4.0.2 spec/httpi/cookie_spec.rb
httpi-4.0.1 spec/httpi/cookie_spec.rb
httpi-3.0.2 spec/httpi/cookie_spec.rb
httpi-3.0.1 spec/httpi/cookie_spec.rb
httpi-3.0.0 spec/httpi/cookie_spec.rb
httpi-2.5.0 spec/httpi/cookie_spec.rb
httpi-2.4.5 spec/httpi/cookie_spec.rb
httpi-2.4.4 spec/httpi/cookie_spec.rb
httpi-2.4.3 spec/httpi/cookie_spec.rb
httpi-2.4.2 spec/httpi/cookie_spec.rb
httpi-2.4.1 spec/httpi/cookie_spec.rb
httpi-2.4.0 spec/httpi/cookie_spec.rb
httpi-2.3.0 spec/httpi/cookie_spec.rb
httpi-2.2.7 spec/httpi/cookie_spec.rb
httpi-2.2.6 spec/httpi/cookie_spec.rb
httpi-2.2.5 spec/httpi/cookie_spec.rb
httpi-2.2.4 spec/httpi/cookie_spec.rb
httpi-2.2.3 spec/httpi/cookie_spec.rb
httpi-2.2.1 spec/httpi/cookie_spec.rb