Sha256: 81fe03a8c747b2970d31d360384e7a0220bcdc1545309da0aeeca2539c2e3543

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path(File.join(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

7 entries across 7 versions & 7 rubygems

Version Path
dbalatero-httparty-0.4.4 spec/httparty/cookie_hash_spec.rb
geetarista-httparty-0.4.5 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.4.4 spec/httparty/cookie_hash_spec.rb
nullstyle-httparty-0.4.4 spec/httparty/cookie_hash_spec.rb
kerryb-httparty-0.4.4 spec/httparty/cookie_hash_spec.rb
yyyc514-httparty-0.4.4.2 spec/httparty/cookie_hash_spec.rb
httparty-0.4.4 spec/httparty/cookie_hash_spec.rb