mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
95e8c48dd3
* For easier modifications of ruby/spec by MRI developers. * .gitignore: track changes under spec. * spec/mspec, spec/rubyspec: add in-tree mspec and ruby/spec. These files can therefore be updated like any other file in MRI. Instructions are provided in spec/README. [Feature #13156] [ruby-core:79246] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
29 lines
1.2 KiB
Ruby
29 lines
1.2 KiB
Ruby
require File.expand_path('../../../../spec_helper', __FILE__)
|
|
require 'cgi'
|
|
|
|
describe "CGI::Cookie#to_s" do
|
|
it "returns a String representation of self" do
|
|
cookie = CGI::Cookie.new("test-cookie")
|
|
cookie.to_s.should == "test-cookie=; path="
|
|
|
|
cookie = CGI::Cookie.new("test-cookie", "value")
|
|
cookie.to_s.should == "test-cookie=value; path="
|
|
|
|
cookie = CGI::Cookie.new("test-cookie", "one", "two", "three")
|
|
cookie.to_s.should == "test-cookie=one&two&three; path="
|
|
|
|
cookie = CGI::Cookie.new(
|
|
'name' => 'test-cookie',
|
|
'value' => ["one", "two", "three"],
|
|
'path' => 'some/path/',
|
|
'domain' => 'example.com',
|
|
'expires' => Time.at(1196524602),
|
|
'secure' => true)
|
|
cookie.to_s.should == "test-cookie=one&two&three; domain=example.com; path=some/path/; expires=Sat, 01 Dec 2007 15:56:42 GMT; secure"
|
|
end
|
|
|
|
it "escapes the self's values" do
|
|
cookie = CGI::Cookie.new("test-cookie", " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")
|
|
cookie.to_s.should == "test-cookie=+%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E; path="
|
|
end
|
|
end
|