Sha256: 48e934fc3a6a2cd7c9573c3c1a28078ecc79269134bae86fd9be378065bf8b91

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe HTTParty::CookieHash do
  before(:each) do
    @cookie_hash = HTTParty::CookieHash.new
  end

  describe "#add_cookies" do
    it "should add new key/value pairs to the hash" do
      @cookie_hash.add_cookies(:foo => "bar")
      @cookie_hash.add_cookies(:rofl => "copter")
      @cookie_hash.length.should eql(2)
    end

    it "should overwrite any existing key" do
      @cookie_hash.add_cookies(:foo => "bar")
      @cookie_hash.add_cookies(:foo => "copter")
      @cookie_hash.length.should eql(1)
      @cookie_hash[:foo].should eql("copter")
    end
  end

  # The regexen are required because Hashes aren't ordered, so a test against
  # a hardcoded string was randomly failing.
  describe "#to_cookie_string" do
    before(:each) do
      @cookie_hash.add_cookies(:foo => "bar")
      @cookie_hash.add_cookies(:rofl => "copter")
      @s = @cookie_hash.to_cookie_string
    end

    it "should format the key/value pairs, delimited by semi-colons" do
      @s.should match(/foo=bar/)
      @s.should match(/rofl=copter/)
      @s.should match(/^\w+=\w+; \w+=\w+$/)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spreedly-1.3.5 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.3.4 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.3.3 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.3.2 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.3.1 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.0.0 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.0.1 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.2.0 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.2.2 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.1.0 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.3.0 vendor/httparty/spec/httparty/cookie_hash_spec.rb
spreedly-1.2.1 vendor/httparty/spec/httparty/cookie_hash_spec.rb