rack-test 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{History.txt → History.md} +70 -58
- data/README.md +110 -0
- data/lib/rack/test.rb +12 -7
- data/lib/rack/test/cookie_jar.rb +17 -1
- data/lib/rack/test/uploaded_file.rb +12 -1
- data/lib/rack/test/utils.rb +19 -13
- data/lib/rack/test/version.rb +5 -0
- metadata +138 -59
- data/.document +0 -4
- data/.gitignore +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -41
- data/README.rdoc +0 -85
- data/Rakefile +0 -33
- data/Thorfile +0 -114
- data/rack-test.gemspec +0 -77
- data/spec/fixtures/bar.txt +0 -1
- data/spec/fixtures/config.ru +0 -3
- data/spec/fixtures/fake_app.rb +0 -143
- data/spec/fixtures/foo.txt +0 -1
- data/spec/rack/test/cookie_spec.rb +0 -219
- data/spec/rack/test/digest_auth_spec.rb +0 -46
- data/spec/rack/test/multipart_spec.rb +0 -145
- data/spec/rack/test/uploaded_file_spec.rb +0 -24
- data/spec/rack/test/utils_spec.rb +0 -193
- data/spec/rack/test_spec.rb +0 -550
- data/spec/spec_helper.rb +0 -69
- data/spec/support/matchers/body.rb +0 -9
- data/spec/support/matchers/challenge.rb +0 -11
data/Rakefile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
|
3
|
-
|
4
|
-
require 'rspec/core'
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new do |t|
|
8
|
-
t.pattern = "./**/*_spec.rb"
|
9
|
-
t.ruby_opts = "-w"
|
10
|
-
end
|
11
|
-
|
12
|
-
task :default => :spec
|
13
|
-
|
14
|
-
# desc "Run all specs in spec directory with RCov"
|
15
|
-
# RSpec::Core::RakeTask.new(:rcov) do |t|
|
16
|
-
# t.libs << 'lib'
|
17
|
-
# t.libs << 'spec'
|
18
|
-
# t.warning = true
|
19
|
-
# t.rcov = true
|
20
|
-
# t.rcov_opts = ['-x spec']
|
21
|
-
# end
|
22
|
-
|
23
|
-
desc "Generate RDoc"
|
24
|
-
task :docs do
|
25
|
-
FileUtils.rm_rf("doc")
|
26
|
-
require "rack/test"
|
27
|
-
system "hanna --title 'Rack::Test #{Rack::Test::VERSION} API Documentation'"
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Removes trailing whitespace'
|
31
|
-
task :whitespace do
|
32
|
-
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
33
|
-
end
|
data/Thorfile
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
module GemHelpers
|
2
|
-
|
3
|
-
def generate_gemspec
|
4
|
-
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
|
5
|
-
require "rack/test"
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "rack-test"
|
9
|
-
s.version = Rack::Test::VERSION
|
10
|
-
s.author = "Bryan Helmkamp"
|
11
|
-
s.email = "bryan@brynary.com"
|
12
|
-
s.homepage = "http://github.com/brynary/rack-test"
|
13
|
-
s.summary = "Simple testing API built on Rack"
|
14
|
-
s.description = <<-EOS.strip
|
15
|
-
Rack::Test is a small, simple testing API for Rack apps. It can be used on its
|
16
|
-
own or as a reusable starting point for Web frameworks and testing libraries
|
17
|
-
to build on. Most of its initial functionality is an extraction of Merb 1.0's
|
18
|
-
request helpers feature.
|
19
|
-
EOS
|
20
|
-
s.rubyforge_project = "rack-test"
|
21
|
-
|
22
|
-
require "git"
|
23
|
-
repo = Git.open(".")
|
24
|
-
|
25
|
-
s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
|
26
|
-
s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
|
27
|
-
|
28
|
-
s.has_rdoc = true
|
29
|
-
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt]
|
30
|
-
|
31
|
-
s.add_dependency "rack", ">= 1.0"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def normalize_files(array)
|
36
|
-
# only keep files, no directories, and sort
|
37
|
-
array.select do |path|
|
38
|
-
File.file?(path)
|
39
|
-
end.sort
|
40
|
-
end
|
41
|
-
|
42
|
-
# Adds extra space when outputting an array. This helps create better version
|
43
|
-
# control diffs, because otherwise it is all on the same line.
|
44
|
-
def prettyify_array(gemspec_ruby, array_name)
|
45
|
-
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
46
|
-
leadin, files = match[0..-2].split("[")
|
47
|
-
leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def read_gemspec
|
52
|
-
@read_gemspec ||= eval(File.read("rack-test.gemspec"))
|
53
|
-
end
|
54
|
-
|
55
|
-
def sh(command)
|
56
|
-
puts command
|
57
|
-
system command
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class Default < Thor
|
62
|
-
include GemHelpers
|
63
|
-
|
64
|
-
desc "gemspec", "Regenerate rack-test.gemspec"
|
65
|
-
def gemspec
|
66
|
-
File.open("rack-test.gemspec", "w") do |file|
|
67
|
-
gemspec_ruby = generate_gemspec.to_ruby
|
68
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :files)
|
69
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
|
70
|
-
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
|
71
|
-
|
72
|
-
file.write gemspec_ruby
|
73
|
-
end
|
74
|
-
|
75
|
-
puts "Wrote gemspec to rack-test.gemspec"
|
76
|
-
read_gemspec.validate
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "build", "Build a rack-test gem"
|
80
|
-
def build
|
81
|
-
sh "gem build rack-test.gemspec"
|
82
|
-
FileUtils.mkdir_p "pkg"
|
83
|
-
FileUtils.mv read_gemspec.file_name, "pkg"
|
84
|
-
end
|
85
|
-
|
86
|
-
desc "install", "Install the latest built gem"
|
87
|
-
def install
|
88
|
-
sh "gem install --local pkg/#{read_gemspec.file_name}"
|
89
|
-
end
|
90
|
-
|
91
|
-
desc "release", "Release the current branch to GitHub and Gemcutter"
|
92
|
-
def release
|
93
|
-
gemspec
|
94
|
-
build
|
95
|
-
Release.new.tag
|
96
|
-
Release.new.gem
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class Release < Thor
|
101
|
-
include GemHelpers
|
102
|
-
|
103
|
-
desc "tag", "Tag the gem on the origin server"
|
104
|
-
def tag
|
105
|
-
release_tag = "v#{read_gemspec.version}"
|
106
|
-
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
|
107
|
-
sh "git push origin #{release_tag}"
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "gem", "Push the gem to Gemcutter"
|
111
|
-
def gem
|
112
|
-
sh "gem push pkg/#{read_gemspec.file_name}"
|
113
|
-
end
|
114
|
-
end
|
data/rack-test.gemspec
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = "rack-test"
|
5
|
-
s.version = "0.6.3"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Bryan Helmkamp"]
|
9
|
-
s.date = "2015-01-09"
|
10
|
-
s.description = "Rack::Test is a small, simple testing API for Rack apps. It can be used on its\nown or as a reusable starting point for Web frameworks and testing libraries\nto build on. Most of its initial functionality is an extraction of Merb 1.0's\nrequest helpers feature."
|
11
|
-
s.email = "bryan@brynary.com"
|
12
|
-
s.extra_rdoc_files = [
|
13
|
-
"README.rdoc",
|
14
|
-
"MIT-LICENSE.txt"
|
15
|
-
]
|
16
|
-
s.files = [
|
17
|
-
".document",
|
18
|
-
".gitignore",
|
19
|
-
"Gemfile",
|
20
|
-
"Gemfile.lock",
|
21
|
-
"History.txt",
|
22
|
-
"MIT-LICENSE.txt",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"Thorfile",
|
26
|
-
"lib/rack/mock_session.rb",
|
27
|
-
"lib/rack/test.rb",
|
28
|
-
"lib/rack/test/cookie_jar.rb",
|
29
|
-
"lib/rack/test/methods.rb",
|
30
|
-
"lib/rack/test/mock_digest_request.rb",
|
31
|
-
"lib/rack/test/uploaded_file.rb",
|
32
|
-
"lib/rack/test/utils.rb",
|
33
|
-
"rack-test.gemspec",
|
34
|
-
"spec/fixtures/bar.txt",
|
35
|
-
"spec/fixtures/config.ru",
|
36
|
-
"spec/fixtures/fake_app.rb",
|
37
|
-
"spec/fixtures/foo.txt",
|
38
|
-
"spec/rack/test/cookie_spec.rb",
|
39
|
-
"spec/rack/test/digest_auth_spec.rb",
|
40
|
-
"spec/rack/test/multipart_spec.rb",
|
41
|
-
"spec/rack/test/uploaded_file_spec.rb",
|
42
|
-
"spec/rack/test/utils_spec.rb",
|
43
|
-
"spec/rack/test_spec.rb",
|
44
|
-
"spec/spec_helper.rb",
|
45
|
-
"spec/support/matchers/body.rb",
|
46
|
-
"spec/support/matchers/challenge.rb"
|
47
|
-
]
|
48
|
-
s.homepage = "http://github.com/brynary/rack-test"
|
49
|
-
s.require_paths = ["lib"]
|
50
|
-
s.rubyforge_project = "rack-test"
|
51
|
-
s.rubygems_version = "1.8.23"
|
52
|
-
s.summary = "Simple testing API built on Rack"
|
53
|
-
s.test_files = [
|
54
|
-
"spec/fixtures/fake_app.rb",
|
55
|
-
"spec/rack/test/cookie_spec.rb",
|
56
|
-
"spec/rack/test/digest_auth_spec.rb",
|
57
|
-
"spec/rack/test/multipart_spec.rb",
|
58
|
-
"spec/rack/test/uploaded_file_spec.rb",
|
59
|
-
"spec/rack/test/utils_spec.rb",
|
60
|
-
"spec/rack/test_spec.rb",
|
61
|
-
"spec/spec_helper.rb",
|
62
|
-
"spec/support/matchers/body.rb",
|
63
|
-
"spec/support/matchers/challenge.rb"
|
64
|
-
]
|
65
|
-
|
66
|
-
if s.respond_to? :specification_version then
|
67
|
-
s.specification_version = 3
|
68
|
-
|
69
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
|
-
s.add_runtime_dependency(%q<rack>, [">= 1.0"])
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
73
|
-
end
|
74
|
-
else
|
75
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
76
|
-
end
|
77
|
-
end
|
data/spec/fixtures/bar.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
baz
|
data/spec/fixtures/config.ru
DELETED
data/spec/fixtures/fake_app.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "sinatra/base"
|
3
|
-
|
4
|
-
module Rack
|
5
|
-
module Test
|
6
|
-
|
7
|
-
class FakeApp < Sinatra::Base
|
8
|
-
head "/" do
|
9
|
-
"meh"
|
10
|
-
end
|
11
|
-
|
12
|
-
options "/" do
|
13
|
-
[200, {}, ""]
|
14
|
-
end
|
15
|
-
|
16
|
-
get "/" do
|
17
|
-
"Hello, GET: #{params.inspect}"
|
18
|
-
end
|
19
|
-
|
20
|
-
get "/redirect" do
|
21
|
-
redirect "/redirected"
|
22
|
-
end
|
23
|
-
|
24
|
-
get "/redirected" do
|
25
|
-
"You've been redirected"
|
26
|
-
end
|
27
|
-
|
28
|
-
get "/void" do
|
29
|
-
[200, {}, ""]
|
30
|
-
end
|
31
|
-
|
32
|
-
get "/cookies/show" do
|
33
|
-
request.cookies.inspect
|
34
|
-
end
|
35
|
-
|
36
|
-
get "/COOKIES/show" do
|
37
|
-
request.cookies.inspect
|
38
|
-
end
|
39
|
-
|
40
|
-
get "/not-cookies/show" do
|
41
|
-
request.cookies.inspect
|
42
|
-
end
|
43
|
-
|
44
|
-
get "/cookies/set-secure" do
|
45
|
-
raise if params["value"].nil?
|
46
|
-
|
47
|
-
response.set_cookie("secure-cookie", :value => params["value"], :secure => true)
|
48
|
-
"Set"
|
49
|
-
end
|
50
|
-
|
51
|
-
get "/cookies/set-simple" do
|
52
|
-
raise if params["value"].nil?
|
53
|
-
|
54
|
-
response.set_cookie "simple", params["value"]
|
55
|
-
"Set"
|
56
|
-
end
|
57
|
-
|
58
|
-
post "/cookies/default-path" do
|
59
|
-
raise if params["value"].nil?
|
60
|
-
|
61
|
-
response.set_cookie "simple", params["value"]
|
62
|
-
"Set"
|
63
|
-
end
|
64
|
-
|
65
|
-
get "/cookies/default-path" do
|
66
|
-
response.cookies.inspect
|
67
|
-
end
|
68
|
-
|
69
|
-
get "/cookies/delete" do
|
70
|
-
response.delete_cookie "value"
|
71
|
-
end
|
72
|
-
|
73
|
-
get "/cookies/count" do
|
74
|
-
old_value = request.cookies["count"].to_i || 0
|
75
|
-
new_value = (old_value + 1).to_s
|
76
|
-
|
77
|
-
response.set_cookie("count", :value => new_value)
|
78
|
-
new_value
|
79
|
-
end
|
80
|
-
|
81
|
-
get "/cookies/set" do
|
82
|
-
raise if params["value"].nil?
|
83
|
-
|
84
|
-
response.set_cookie("value", {
|
85
|
-
:value => params["value"],
|
86
|
-
:path => "/cookies",
|
87
|
-
:expires => Time.now + 10
|
88
|
-
})
|
89
|
-
"Set"
|
90
|
-
end
|
91
|
-
|
92
|
-
get "/cookies/domain" do
|
93
|
-
old_value = request.cookies["count"].to_i || 0
|
94
|
-
new_value = (old_value + 1).to_s
|
95
|
-
|
96
|
-
response.set_cookie("count", :value => new_value, :domain => "localhost.com")
|
97
|
-
new_value
|
98
|
-
end
|
99
|
-
|
100
|
-
get "/cookies/subdomain" do
|
101
|
-
old_value = request.cookies["count"].to_i || 0
|
102
|
-
new_value = (old_value + 1).to_s
|
103
|
-
|
104
|
-
response.set_cookie("count", :value => new_value, :domain => ".example.org")
|
105
|
-
new_value
|
106
|
-
end
|
107
|
-
|
108
|
-
get "/cookies/set-uppercase" do
|
109
|
-
raise if params["value"].nil?
|
110
|
-
|
111
|
-
response.set_cookie("VALUE", {
|
112
|
-
:value => params["value"],
|
113
|
-
:path => "/cookies",
|
114
|
-
:expires => Time.now + 10
|
115
|
-
})
|
116
|
-
"Set"
|
117
|
-
end
|
118
|
-
|
119
|
-
get "/cookies/set-multiple" do
|
120
|
-
response.set_cookie("key1", :value => "value1")
|
121
|
-
response.set_cookie("key2", :value => "value2")
|
122
|
-
"Set"
|
123
|
-
end
|
124
|
-
|
125
|
-
post "/" do
|
126
|
-
"Hello, POST: #{params.inspect}"
|
127
|
-
end
|
128
|
-
|
129
|
-
put "/" do
|
130
|
-
"Hello, PUT: #{params.inspect}"
|
131
|
-
end
|
132
|
-
|
133
|
-
patch "/" do
|
134
|
-
"Hello, PUT: #{params.inspect}"
|
135
|
-
end
|
136
|
-
|
137
|
-
delete "/" do
|
138
|
-
"Hello, DELETE: #{params.inspect}"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
data/spec/fixtures/foo.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
bar
|
@@ -1,219 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Rack::Test::Session do
|
4
|
-
|
5
|
-
context "cookies" do
|
6
|
-
it "keeps a cookie jar" do
|
7
|
-
get "/cookies/show"
|
8
|
-
check last_request.cookies.should == {}
|
9
|
-
|
10
|
-
get "/cookies/set", "value" => "1"
|
11
|
-
get "/cookies/show"
|
12
|
-
last_request.cookies.should == { "value" => "1" }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "doesn't send expired cookies" do
|
16
|
-
get "/cookies/set", "value" => "1"
|
17
|
-
now = Time.now
|
18
|
-
Time.stub!(:now => now + 60)
|
19
|
-
get "/cookies/show"
|
20
|
-
last_request.cookies.should == {}
|
21
|
-
end
|
22
|
-
|
23
|
-
it "cookie path defaults to the uri of the document that was requested" do
|
24
|
-
pending "See issue rack-test github issue #50" do
|
25
|
-
post "/cookies/default-path", "value" => "cookie"
|
26
|
-
get "/cookies/default-path"
|
27
|
-
check last_request.cookies.should == { "simple"=>"cookie" }
|
28
|
-
get "/cookies/show"
|
29
|
-
check last_request.cookies.should == { }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "escapes cookie values" do
|
34
|
-
jar = Rack::Test::CookieJar.new
|
35
|
-
jar["value"] = "foo;abc"
|
36
|
-
jar["value"].should == "foo;abc"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "deletes cookies directly from the CookieJar" do
|
40
|
-
jar = Rack::Test::CookieJar.new
|
41
|
-
jar["abcd"] = "1234"
|
42
|
-
jar["abcd"].should == "1234"
|
43
|
-
jar.delete("abcd")
|
44
|
-
jar["abcd"].should == nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it "doesn't send cookies with the wrong domain" do
|
48
|
-
get "http://www.example.com/cookies/set", "value" => "1"
|
49
|
-
get "http://www.other.example/cookies/show"
|
50
|
-
last_request.cookies.should == {}
|
51
|
-
end
|
52
|
-
|
53
|
-
it "doesn't send cookies with the wrong path" do
|
54
|
-
get "/cookies/set", "value" => "1"
|
55
|
-
get "/not-cookies/show"
|
56
|
-
last_request.cookies.should == {}
|
57
|
-
end
|
58
|
-
|
59
|
-
it "persists cookies across requests that don't return any cookie headers" do
|
60
|
-
get "/cookies/set", "value" => "1"
|
61
|
-
get "/void"
|
62
|
-
get "/cookies/show"
|
63
|
-
last_request.cookies.should == { "value" => "1" }
|
64
|
-
end
|
65
|
-
|
66
|
-
it "deletes cookies" do
|
67
|
-
get "/cookies/set", "value" => "1"
|
68
|
-
get "/cookies/delete"
|
69
|
-
get "/cookies/show"
|
70
|
-
last_request.cookies.should == { }
|
71
|
-
end
|
72
|
-
|
73
|
-
it "respects cookie domains when no domain is explicitly set" do
|
74
|
-
pending "FIXME: www.example.org should not get the first cookie" do
|
75
|
-
request("http://example.org/cookies/count").should have_body("1")
|
76
|
-
request("http://www.example.org/cookies/count").should have_body("1")
|
77
|
-
request("http://example.org/cookies/count").should have_body("2")
|
78
|
-
request("http://www.example.org/cookies/count").should have_body("2")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "treats domains case insensitively" do
|
83
|
-
get "http://example.com/cookies/set", "value" => "1"
|
84
|
-
get "http://EXAMPLE.COM/cookies/show"
|
85
|
-
last_request.cookies.should == { "value" => "1" }
|
86
|
-
end
|
87
|
-
|
88
|
-
it "treats paths case sensitively" do
|
89
|
-
get "/cookies/set", "value" => "1"
|
90
|
-
get "/COOKIES/show"
|
91
|
-
last_request.cookies.should == {}
|
92
|
-
end
|
93
|
-
|
94
|
-
it "prefers more specific cookies" do
|
95
|
-
get "http://example.com/cookies/set", "value" => "domain"
|
96
|
-
get "http://sub.example.com/cookies/set", "value" => "sub"
|
97
|
-
|
98
|
-
get "http://sub.example.com/cookies/show"
|
99
|
-
check last_request.cookies.should == { "value" => "sub" }
|
100
|
-
|
101
|
-
get "http://example.com/cookies/show"
|
102
|
-
last_request.cookies.should == { "value" => "domain" }
|
103
|
-
end
|
104
|
-
|
105
|
-
it "treats cookie names case insensitively" do
|
106
|
-
get "/cookies/set", "value" => "lowercase"
|
107
|
-
get "/cookies/set-uppercase", "value" => "UPPERCASE"
|
108
|
-
get "/cookies/show"
|
109
|
-
last_request.cookies.should == { "VALUE" => "UPPERCASE" }
|
110
|
-
end
|
111
|
-
|
112
|
-
it "defaults the domain to the request domain" do
|
113
|
-
get "http://example.com/cookies/set-simple", "value" => "cookie"
|
114
|
-
get "http://example.com/cookies/show"
|
115
|
-
check last_request.cookies.should == { "simple" => "cookie" }
|
116
|
-
|
117
|
-
get "http://other.example/cookies/show"
|
118
|
-
last_request.cookies.should == {}
|
119
|
-
end
|
120
|
-
|
121
|
-
it "defaults the domain to the request path up to the last slash" do
|
122
|
-
get "/cookies/set-simple", "value" => "1"
|
123
|
-
get "/not-cookies/show"
|
124
|
-
last_request.cookies.should == {}
|
125
|
-
end
|
126
|
-
|
127
|
-
it "supports secure cookies" do
|
128
|
-
get "https://example.com/cookies/set-secure", "value" => "set"
|
129
|
-
get "http://example.com/cookies/show"
|
130
|
-
check last_request.cookies.should == {}
|
131
|
-
|
132
|
-
get "https://example.com/cookies/show"
|
133
|
-
last_request.cookies.should == { "secure-cookie" => "set" }
|
134
|
-
rack_mock_session.cookie_jar['secure-cookie'].should == 'set'
|
135
|
-
end
|
136
|
-
|
137
|
-
it "keeps separate cookie jars for different domains" do
|
138
|
-
get "http://example.com/cookies/set", "value" => "example"
|
139
|
-
get "http://example.com/cookies/show"
|
140
|
-
check last_request.cookies.should == { "value" => "example" }
|
141
|
-
|
142
|
-
get "http://other.example/cookies/set", "value" => "other"
|
143
|
-
get "http://other.example/cookies/show"
|
144
|
-
check last_request.cookies.should == { "value" => "other" }
|
145
|
-
|
146
|
-
get "http://example.com/cookies/show"
|
147
|
-
last_request.cookies.should == { "value" => "example" }
|
148
|
-
end
|
149
|
-
|
150
|
-
it "keeps one cookie jar for domain and its subdomains" do
|
151
|
-
get "http://example.org/cookies/subdomain"
|
152
|
-
get "http://example.org/cookies/subdomain"
|
153
|
-
last_request.cookies.should == { "count" => "1" }
|
154
|
-
|
155
|
-
get "http://foo.example.org/cookies/subdomain"
|
156
|
-
last_request.cookies.should == { "count" => "2" }
|
157
|
-
end
|
158
|
-
|
159
|
-
it "allows cookies to be cleared" do
|
160
|
-
get "/cookies/set", "value" => "1"
|
161
|
-
clear_cookies
|
162
|
-
get "/cookies/show"
|
163
|
-
last_request.cookies.should == {}
|
164
|
-
end
|
165
|
-
|
166
|
-
it "allow cookies to be set" do
|
167
|
-
set_cookie "value=10"
|
168
|
-
get "/cookies/show"
|
169
|
-
last_request.cookies.should == { "value" => "10" }
|
170
|
-
end
|
171
|
-
|
172
|
-
it "allows an array of cookies to be set" do
|
173
|
-
set_cookie ["value=10", "foo=bar"]
|
174
|
-
get "/cookies/show"
|
175
|
-
last_request.cookies.should == { "value" => "10", "foo" => "bar" }
|
176
|
-
end
|
177
|
-
|
178
|
-
it "skips emtpy string cookies" do
|
179
|
-
set_cookie "value=10\n\nfoo=bar"
|
180
|
-
get "/cookies/show"
|
181
|
-
last_request.cookies.should == { "value" => "10", "foo" => "bar" }
|
182
|
-
end
|
183
|
-
|
184
|
-
it "parses multiple cookies properly" do
|
185
|
-
get "/cookies/set-multiple"
|
186
|
-
get "/cookies/show"
|
187
|
-
last_request.cookies.should == { "key1" => "value1", "key2" => "value2" }
|
188
|
-
end
|
189
|
-
|
190
|
-
it "supports multiple sessions" do
|
191
|
-
with_session(:first) do
|
192
|
-
get "/cookies/set", "value" => "1"
|
193
|
-
get "/cookies/show"
|
194
|
-
last_request.cookies.should == { "value" => "1" }
|
195
|
-
end
|
196
|
-
|
197
|
-
with_session(:second) do
|
198
|
-
get "/cookies/show"
|
199
|
-
last_request.cookies.should == { }
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
it "uses :default as the default session name" do
|
204
|
-
get "/cookies/set", "value" => "1"
|
205
|
-
get "/cookies/show"
|
206
|
-
check last_request.cookies.should == { "value" => "1" }
|
207
|
-
|
208
|
-
with_session(:default) do
|
209
|
-
get "/cookies/show"
|
210
|
-
last_request.cookies.should == { "value" => "1" }
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
it "accepts explicitly provided cookies" do
|
215
|
-
request "/cookies/show", :cookie => "value=1"
|
216
|
-
last_request.cookies.should == { "value" => "1" }
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|