Sha256: 8fa39fa899e0dd536e8ca2b3d635c59a337a635a549186951980c4427b0cf391

Contents?: true

Size: 771 Bytes

Versions: 8

Compression:

Stored size: 771 Bytes

Contents

require "spec_helper"
require "httpi"

describe HTTPI::CookieStore do

  let(:user_cookie)  { some_cookie(:user, "chucknorris") }
  let(:token_cookie) { some_cookie(:token, "strawberry") }

  it "stores a set of cookies" do
    cookie_store = HTTPI::CookieStore.new
    cookie_store.add(user_cookie, token_cookie)
    cookie_store.fetch.should include("user=chucknorris", "token=strawberry")

    # add a new token cookie with a different value
    token_cookie = some_cookie(:token, "choc-choc-chip")
    cookie_store.add(token_cookie)

    cookie_store.fetch.should include("token=choc-choc-chip")
    cookie_store.fetch.should_not include("token=strawberry")
  end

  def some_cookie(name, value)
    HTTPI::Cookie.new("#{name}=#{value}; Path=/; HttpOnly")
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
httpi-2.1.1 spec/httpi/cookie_store_spec.rb
httpi-2.1.0 spec/httpi/cookie_store_spec.rb
httpi-2.0.2 spec/httpi/cookie_store_spec.rb
httpi-2.0.1 spec/httpi/cookie_store_spec.rb
httpi-2.0.0 spec/httpi/cookie_store_spec.rb
httpi-2.0.0.rc1 spec/httpi/cookie_store_spec.rb
httpi-1.1.1 spec/httpi/cookie_store_spec.rb
httpi-1.1.0 spec/httpi/cookie_store_spec.rb