Sha256: 0640d06a58a271330a287244e362dd9ae15e95fe6f855aaadc383fbc156bd694

Contents?: true

Size: 1.14 KB

Versions: 28

Compression:

Stored size: 1.14 KB

Contents

require 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

28 entries across 28 versions & 9 rubygems

Version Path
alexvollmer-httparty-0.3.1 spec/httparty/cookie_hash_spec.rb
alexvollmer-httparty-0.4.3 spec/httparty/cookie_hash_spec.rb
cluon-httparty-0.4.3 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.2.10 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.2.9 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.3.0 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.3.1 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.4.0 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.4.1 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.4.2 spec/httparty/cookie_hash_spec.rb
jnunemaker-httparty-0.4.3 spec/httparty/cookie_hash_spec.rb
kerryb-httparty-0.3.2 spec/httparty/cookie_hash_spec.rb
kerryb-httparty-0.3.3 spec/httparty/cookie_hash_spec.rb
kerryb-httparty-0.4.3 spec/httparty/cookie_hash_spec.rb
leh-httparty-0.3.1.1 spec/httparty/cookie_hash_spec.rb
mfilej-httparty-0.4.3 spec/httparty/cookie_hash_spec.rb
timriley-httparty-0.3.1 spec/httparty/cookie_hash_spec.rb
timriley-httparty-0.3.2 spec/httparty/cookie_hash_spec.rb
voxdolo-httparty-0.3.1 spec/httparty/cookie_hash_spec.rb
voxdolo-httparty-0.4.1 spec/httparty/cookie_hash_spec.rb