middleman 0.5.5 → 0.9.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +1 -2
- data/.gitignore +3 -2
- data/LICENSE +0 -0
- data/README.rdoc +4 -0
- data/Rakefile +28 -36
- data/VERSION +1 -1
- data/bin/mm-build +7 -113
- data/bin/mm-init +11 -5
- data/bin/mm-server +56 -3
- data/features/asset_host.feature +12 -0
- data/features/automatic_image_sizes.feature +14 -0
- data/features/cache_buster.feature +22 -0
- data/features/generator.feature +8 -0
- data/features/minify_css.feature +22 -0
- data/features/minify_javascript.feature +12 -0
- data/features/page_alias_and_layouts.feature +12 -0
- data/features/relative_assets.feature +12 -0
- data/features/step_definitions/asset_host_steps.rb +7 -0
- data/features/step_definitions/env.rb +3 -0
- data/features/step_definitions/generator_steps.rb +24 -0
- data/features/step_definitions/middleman_steps.rb +28 -0
- data/features/step_definitions/page_layout_steps.rb +13 -0
- data/lib/middleman.rb +6 -132
- data/lib/middleman/assets.rb +33 -0
- data/lib/middleman/base.rb +147 -0
- data/lib/middleman/builder.rb +59 -0
- data/lib/middleman/config.ru +2 -0
- data/lib/middleman/features.rb +39 -0
- data/lib/middleman/features/asset_host.rb +21 -0
- data/lib/middleman/features/automatic_image_sizes.rb +31 -0
- data/lib/middleman/features/automatic_image_sizes/fastimage.rb +282 -0
- data/lib/middleman/features/cache_buster.rb +43 -0
- data/lib/middleman/features/default_helpers.rb +68 -0
- data/lib/middleman/features/livereload.rb +19 -0
- data/lib/middleman/features/minify_css.rb +9 -0
- data/lib/middleman/features/minify_javascript.rb +20 -0
- data/lib/middleman/features/minify_javascript/rack.rb +31 -0
- data/lib/middleman/features/relative_assets.rb +35 -0
- data/lib/middleman/features/slickmap.rb +118 -0
- data/lib/middleman/features/smush_pngs.rb +38 -0
- data/lib/middleman/features/ugly_haml.rb +7 -0
- data/lib/middleman/renderers.rb +26 -0
- data/lib/middleman/renderers/coffee.rb +28 -0
- data/lib/middleman/renderers/haml.rb +47 -0
- data/lib/middleman/renderers/sass.rb +67 -0
- data/lib/middleman/template/init.rbt +57 -0
- data/lib/middleman/template/views/index.html.haml +4 -0
- data/lib/middleman/template/views/layout.haml +11 -4
- data/lib/middleman/template/views/stylesheets/site.css.sass +27 -0
- data/lib/middleman/templater+dynamic_renderer.rb +26 -0
- data/middleman.gemspec +121 -107
- data/spec/builder_spec.rb +17 -16
- data/spec/fixtures/sample/init.rb +28 -2
- data/spec/fixtures/sample/public/images/blank.gif +0 -0
- data/spec/fixtures/sample/public/static.html +0 -0
- data/{vendor/sinatra-maruku/examples/public/javascripts/application.js → spec/fixtures/sample/public/stylesheets/auto-css.css} +0 -0
- data/spec/fixtures/sample/public/stylesheets/static.css +0 -0
- data/{vendor/sinatra-maruku/examples/public/stylesheets/print.css → spec/fixtures/sample/public/stylesheets/sub1/auto-css.css} +0 -0
- data/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css +0 -0
- data/spec/fixtures/sample/views/_partial.haml +0 -0
- data/spec/fixtures/sample/views/asset_host.html.haml +1 -0
- data/spec/fixtures/sample/views/auto-css.html.haml +1 -0
- data/spec/fixtures/sample/views/auto-image-sizes.html.haml +1 -0
- data/spec/fixtures/sample/views/cache-buster.html.haml +2 -0
- data/spec/fixtures/sample/views/{index.haml → custom-layout.html.haml} +0 -0
- data/spec/fixtures/sample/views/custom.haml +5 -0
- data/spec/fixtures/sample/views/index.html.haml +1 -0
- data/spec/fixtures/sample/views/inline-css.html.haml +4 -0
- data/spec/fixtures/sample/views/{inline-js.haml → inline-js.html.haml} +0 -0
- data/spec/fixtures/sample/views/layout.haml +1 -1
- data/spec/fixtures/sample/views/{maruku.maruku → maruku.html.maruku} +0 -0
- data/spec/fixtures/sample/views/page-classes.html.haml +1 -0
- data/spec/fixtures/sample/views/services/{index.haml → index.html.haml} +0 -0
- data/spec/fixtures/sample/views/stylesheets/asset_host.css.sass +3 -0
- data/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass +3 -0
- data/spec/fixtures/sample/views/stylesheets/site.css.sass +1 -0
- data/spec/fixtures/sample/views/stylesheets/site_scss.css.scss +1 -0
- data/spec/fixtures/sample/views/stylesheets/test_less.css.less +5 -0
- data/spec/helpers_spec.rb +43 -0
- data/spec/spec_helper.rb +3 -5
- metadata +298 -127
- data/lib/middleman/helpers.rb +0 -131
- data/lib/middleman/markaby.rb +0 -4
- data/lib/middleman/maruku.rb +0 -4
- data/lib/middleman/sprockets_ext.rb +0 -29
- data/lib/middleman/template/init.rb +0 -22
- data/lib/middleman/template/views/index.haml +0 -1
- data/lib/middleman/template/views/stylesheets/site.sass +0 -1
- data/spec/fixtures/sample/views/markaby.mab +0 -5
- data/spec/fixtures/sample/views/stylesheets/site.sass +0 -1
- data/spec/generator_spec.rb +0 -34
- data/vendor/rack-test/History.txt +0 -64
- data/vendor/rack-test/MIT-LICENSE.txt +0 -19
- data/vendor/rack-test/README.rdoc +0 -57
- data/vendor/rack-test/Rakefile +0 -62
- data/vendor/rack-test/lib/rack/mock_session.rb +0 -57
- data/vendor/rack-test/lib/rack/test.rb +0 -246
- data/vendor/rack-test/lib/rack/test/cookie_jar.rb +0 -169
- data/vendor/rack-test/lib/rack/test/methods.rb +0 -73
- data/vendor/rack-test/lib/rack/test/mock_digest_request.rb +0 -27
- data/vendor/rack-test/lib/rack/test/uploaded_file.rb +0 -36
- data/vendor/rack-test/lib/rack/test/utils.rb +0 -75
- data/vendor/rack-test/spec/fixtures/config.ru +0 -3
- data/vendor/rack-test/spec/fixtures/fake_app.rb +0 -109
- data/vendor/rack-test/spec/fixtures/foo.txt +0 -1
- data/vendor/rack-test/spec/rack/test/cookie_spec.rb +0 -176
- data/vendor/rack-test/spec/rack/test/digest_auth_spec.rb +0 -48
- data/vendor/rack-test/spec/rack/test/multipart_spec.rb +0 -85
- data/vendor/rack-test/spec/rack/test/utils_spec.rb +0 -44
- data/vendor/rack-test/spec/rack/test_spec.rb +0 -363
- data/vendor/rack-test/spec/rcov.opts +0 -1
- data/vendor/rack-test/spec/spec.opts +0 -1
- data/vendor/rack-test/spec/spec_helper.rb +0 -48
- data/vendor/sinatra-content-for/LICENSE +0 -22
- data/vendor/sinatra-content-for/README.rdoc +0 -49
- data/vendor/sinatra-content-for/Rakefile +0 -33
- data/vendor/sinatra-content-for/lib/sinatra/content_for.rb +0 -58
- data/vendor/sinatra-content-for/sinatra-content-for.gemspec +0 -34
- data/vendor/sinatra-content-for/test/content_for_test.rb +0 -156
- data/vendor/sinatra-markaby/CHANGES +0 -7
- data/vendor/sinatra-markaby/LICENSE +0 -20
- data/vendor/sinatra-markaby/README.rdoc +0 -33
- data/vendor/sinatra-markaby/Rakefile +0 -45
- data/vendor/sinatra-markaby/TODO +0 -3
- data/vendor/sinatra-markaby/VERSION.yml +0 -4
- data/vendor/sinatra-markaby/lib/sinatra/markaby.rb +0 -31
- data/vendor/sinatra-markaby/sinatra-markaby.gemspec +0 -49
- data/vendor/sinatra-markaby/test/sinatra_markaby_test.rb +0 -72
- data/vendor/sinatra-markaby/test/test_helper.rb +0 -19
- data/vendor/sinatra-markaby/test/views/hello.mab +0 -1
- data/vendor/sinatra-markaby/test/views/html.mab +0 -4
- data/vendor/sinatra-maruku/LICENSE +0 -22
- data/vendor/sinatra-maruku/README.markdown +0 -85
- data/vendor/sinatra-maruku/Rakefile +0 -34
- data/vendor/sinatra-maruku/VERSION.yml +0 -4
- data/vendor/sinatra-maruku/examples/app.rb +0 -8
- data/vendor/sinatra-maruku/examples/config.ru +0 -4
- data/vendor/sinatra-maruku/examples/mapp.rb +0 -15
- data/vendor/sinatra-maruku/examples/public/stylesheets/application.css +0 -23
- data/vendor/sinatra-maruku/examples/views/index.maruku +0 -32
- data/vendor/sinatra-maruku/examples/views/layout.maruku +0 -9
- data/vendor/sinatra-maruku/lib/sinatra/maruku.rb +0 -25
- data/vendor/sinatra-maruku/sinatra-maruku.gemspec +0 -70
- data/vendor/sinatra-maruku/test/sinatra_maruku_test.rb +0 -91
- data/vendor/sinatra-maruku/test/test_helper.rb +0 -21
- data/vendor/sinatra-maruku/test/views/hello.maruku +0 -1
- data/vendor/sinatra-maruku/test/views/layout2.maruku +0 -2
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require "forwardable"
|
|
2
|
-
|
|
3
|
-
module Rack
|
|
4
|
-
module Test
|
|
5
|
-
module Methods
|
|
6
|
-
extend Forwardable
|
|
7
|
-
|
|
8
|
-
def rack_mock_session(name = :default)
|
|
9
|
-
return build_rack_mock_session unless name
|
|
10
|
-
|
|
11
|
-
@_rack_mock_sessions ||= {}
|
|
12
|
-
@_rack_mock_sessions[name] ||= build_rack_mock_session
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def build_rack_mock_session
|
|
16
|
-
Rack::MockSession.new(app)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def rack_test_session(name = :default)
|
|
20
|
-
return build_rack_test_session(name) unless name
|
|
21
|
-
|
|
22
|
-
@_rack_test_sessions ||= {}
|
|
23
|
-
@_rack_test_sessions[name] ||= build_rack_test_session(name)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def build_rack_test_session(name)
|
|
27
|
-
Rack::Test::Session.new(rack_mock_session(name))
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def current_session
|
|
31
|
-
rack_test_session(_current_session_names.last)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def with_session(name)
|
|
35
|
-
_current_session_names.push(name)
|
|
36
|
-
yield rack_test_session(name)
|
|
37
|
-
_current_session_names.pop
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def _current_session_names
|
|
41
|
-
@_current_session_names ||= [:default]
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
METHODS = [
|
|
45
|
-
:request,
|
|
46
|
-
|
|
47
|
-
# HTTP verbs
|
|
48
|
-
:get,
|
|
49
|
-
:post,
|
|
50
|
-
:put,
|
|
51
|
-
:delete,
|
|
52
|
-
:head,
|
|
53
|
-
|
|
54
|
-
# Redirects
|
|
55
|
-
:follow_redirect!,
|
|
56
|
-
|
|
57
|
-
# Header-related features
|
|
58
|
-
:header,
|
|
59
|
-
:set_cookie,
|
|
60
|
-
:clear_cookies,
|
|
61
|
-
:authorize,
|
|
62
|
-
:basic_authorize,
|
|
63
|
-
:digest_authorize,
|
|
64
|
-
|
|
65
|
-
# Expose the last request and response
|
|
66
|
-
:last_response,
|
|
67
|
-
:last_request
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
def_delegators :current_session, *METHODS
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Rack
|
|
2
|
-
module Test
|
|
3
|
-
|
|
4
|
-
class MockDigestRequest
|
|
5
|
-
def initialize(params)
|
|
6
|
-
@params = params
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def method_missing(sym)
|
|
10
|
-
if @params.has_key? k = sym.to_s
|
|
11
|
-
return @params[k]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
super
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def method
|
|
18
|
-
@params['method']
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def response(password)
|
|
22
|
-
Rack::Auth::Digest::MD5.new(nil).send :digest, self, password
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require "tempfile"
|
|
2
|
-
|
|
3
|
-
module Rack
|
|
4
|
-
module Test
|
|
5
|
-
|
|
6
|
-
class UploadedFile
|
|
7
|
-
# The filename, *not* including the path, of the "uploaded" file
|
|
8
|
-
attr_reader :original_filename
|
|
9
|
-
|
|
10
|
-
# The content type of the "uploaded" file
|
|
11
|
-
attr_accessor :content_type
|
|
12
|
-
|
|
13
|
-
def initialize(path, content_type = "text/plain", binary = false)
|
|
14
|
-
raise "#{path} file does not exist" unless ::File.exist?(path)
|
|
15
|
-
@content_type = content_type
|
|
16
|
-
@original_filename = ::File.basename(path)
|
|
17
|
-
@tempfile = Tempfile.new(@original_filename)
|
|
18
|
-
@tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
|
|
19
|
-
@tempfile.binmode if binary
|
|
20
|
-
FileUtils.copy_file(path, @tempfile.path)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def path
|
|
24
|
-
@tempfile.path
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
alias_method :local_path, :path
|
|
28
|
-
|
|
29
|
-
def method_missing(method_name, *args, &block) #:nodoc:
|
|
30
|
-
@tempfile.__send__(method_name, *args, &block)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
module Rack
|
|
2
|
-
module Test
|
|
3
|
-
|
|
4
|
-
module Utils
|
|
5
|
-
include Rack::Utils
|
|
6
|
-
|
|
7
|
-
def requestify(value, prefix = nil)
|
|
8
|
-
case value
|
|
9
|
-
when Array
|
|
10
|
-
value.map do |v|
|
|
11
|
-
requestify(v, "#{prefix}[]")
|
|
12
|
-
end.join("&")
|
|
13
|
-
when Hash
|
|
14
|
-
value.map do |k, v|
|
|
15
|
-
requestify(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
|
|
16
|
-
end.join("&")
|
|
17
|
-
else
|
|
18
|
-
"#{prefix}=#{escape(value)}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
module_function :requestify
|
|
23
|
-
|
|
24
|
-
def multipart_requestify(params, first=true)
|
|
25
|
-
p = Hash.new
|
|
26
|
-
|
|
27
|
-
params.each do |key, value|
|
|
28
|
-
k = first ? key.to_s : "[#{key}]"
|
|
29
|
-
|
|
30
|
-
if Hash === value
|
|
31
|
-
multipart_requestify(value, false).each do |subkey, subvalue|
|
|
32
|
-
p[k + subkey] = subvalue
|
|
33
|
-
end
|
|
34
|
-
else
|
|
35
|
-
p[k] = value
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
return p
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
module_function :multipart_requestify
|
|
43
|
-
|
|
44
|
-
def multipart_body(params)
|
|
45
|
-
multipart_requestify(params).map do |key, value|
|
|
46
|
-
if value.respond_to?(:original_filename)
|
|
47
|
-
::File.open(value.path, "rb") do |f|
|
|
48
|
-
f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
|
|
49
|
-
|
|
50
|
-
<<-EOF
|
|
51
|
-
--#{MULTIPART_BOUNDARY}\r
|
|
52
|
-
Content-Disposition: form-data; name="#{key}"; filename="#{escape(value.original_filename)}"\r
|
|
53
|
-
Content-Type: #{value.content_type}\r
|
|
54
|
-
Content-Length: #{::File.stat(value.path).size}\r
|
|
55
|
-
\r
|
|
56
|
-
#{f.read}\r
|
|
57
|
-
EOF
|
|
58
|
-
end
|
|
59
|
-
else
|
|
60
|
-
<<-EOF
|
|
61
|
-
--#{MULTIPART_BOUNDARY}\r
|
|
62
|
-
Content-Disposition: form-data; name="#{key}"\r
|
|
63
|
-
\r
|
|
64
|
-
#{value}\r
|
|
65
|
-
EOF
|
|
66
|
-
end
|
|
67
|
-
end.join("")+"--#{MULTIPART_BOUNDARY}--\r"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
module_function :multipart_body
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
end
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
require "sinatra/base"
|
|
2
|
-
|
|
3
|
-
module Rack
|
|
4
|
-
module Test
|
|
5
|
-
|
|
6
|
-
class FakeApp < Sinatra::Default
|
|
7
|
-
head "/" do
|
|
8
|
-
"meh"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
get "/" do
|
|
12
|
-
"Hello, GET: #{params.inspect}"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
get "/redirect" do
|
|
16
|
-
redirect "/redirected"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
get "/redirected" do
|
|
20
|
-
"You've been redirected"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
get "/void" do
|
|
24
|
-
[200, {}, ""]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
get "/cookies/show" do
|
|
28
|
-
request.cookies.inspect
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
get "/COOKIES/show" do
|
|
32
|
-
request.cookies.inspect
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
get "/not-cookies/show" do
|
|
36
|
-
request.cookies.inspect
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
get "/cookies/set-secure" do
|
|
40
|
-
raise if params["value"].nil?
|
|
41
|
-
|
|
42
|
-
response.set_cookie("secure-cookie", :value => params["value"], :secure => true)
|
|
43
|
-
"Set"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
get "/cookies/set-simple" do
|
|
47
|
-
raise if params["value"].nil?
|
|
48
|
-
|
|
49
|
-
response.set_cookie "simple", params["value"]
|
|
50
|
-
"Set"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
get "/cookies/delete" do
|
|
54
|
-
response.delete_cookie "value"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
get "/cookies/count" do
|
|
58
|
-
old_value = request.cookies["count"].to_i || 0
|
|
59
|
-
new_value = (old_value + 1).to_s
|
|
60
|
-
|
|
61
|
-
response.set_cookie("count", :value => new_value)
|
|
62
|
-
new_value
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
get "/cookies/set" do
|
|
66
|
-
raise if params["value"].nil?
|
|
67
|
-
|
|
68
|
-
response.set_cookie("value", {
|
|
69
|
-
:value => params["value"],
|
|
70
|
-
:path => "/cookies",
|
|
71
|
-
:expires => Time.now + 10
|
|
72
|
-
})
|
|
73
|
-
"Set"
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
get "/cookies/domain" do
|
|
77
|
-
old_value = request.cookies["count"].to_i || 0
|
|
78
|
-
new_value = (old_value + 1).to_s
|
|
79
|
-
|
|
80
|
-
response.set_cookie("count", :value => new_value, :domain => "localhost.com")
|
|
81
|
-
new_value
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
get "/cookies/set-uppercase" do
|
|
85
|
-
raise if params["value"].nil?
|
|
86
|
-
|
|
87
|
-
response.set_cookie("VALUE", {
|
|
88
|
-
:value => params["value"],
|
|
89
|
-
:path => "/cookies",
|
|
90
|
-
:expires => Time.now + 10
|
|
91
|
-
})
|
|
92
|
-
"Set"
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
post "/" do
|
|
96
|
-
"Hello, POST: #{params.inspect}"
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
put "/" do
|
|
100
|
-
"Hello, PUT: #{params.inspect}"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
delete "/" do
|
|
104
|
-
"Hello, DELETE: #{params.inspect}"
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end
|
|
109
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bar
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/../../spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Rack::Test::Session do
|
|
4
|
-
def have_body(string)
|
|
5
|
-
simple_matcher "have body #{string.inspect}" do |response|
|
|
6
|
-
response.body.should == string
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "cookies" do
|
|
11
|
-
it "keeps a cookie jar" do
|
|
12
|
-
get "/cookies/show"
|
|
13
|
-
last_request.cookies.should == {}
|
|
14
|
-
|
|
15
|
-
get "/cookies/set", "value" => "1"
|
|
16
|
-
get "/cookies/show"
|
|
17
|
-
last_request.cookies.should == { "value" => "1" }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "doesn't send expired cookies" do
|
|
21
|
-
get "/cookies/set", "value" => "1"
|
|
22
|
-
now = Time.now
|
|
23
|
-
Time.stub!(:now => now + 60)
|
|
24
|
-
get "/cookies/show"
|
|
25
|
-
last_request.cookies.should == {}
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "doesn't send cookies with the wrong domain" do
|
|
29
|
-
get "http://www.example.com/cookies/set", "value" => "1"
|
|
30
|
-
get "http://www.other.example/cookies/show"
|
|
31
|
-
last_request.cookies.should == {}
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "doesn't send cookies with the wrong path" do
|
|
35
|
-
get "/cookies/set", "value" => "1"
|
|
36
|
-
get "/not-cookies/show"
|
|
37
|
-
last_request.cookies.should == {}
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "persists cookies across requests that don't return any cookie headers" do
|
|
41
|
-
get "/cookies/set", "value" => "1"
|
|
42
|
-
get "/void"
|
|
43
|
-
get "/cookies/show"
|
|
44
|
-
last_request.cookies.should == { "value" => "1" }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "deletes cookies" do
|
|
48
|
-
get "/cookies/set", "value" => "1"
|
|
49
|
-
get "/cookies/delete"
|
|
50
|
-
get "/cookies/show"
|
|
51
|
-
last_request.cookies.should == { }
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
xit "respects cookie domains when no domain is explicitly set" do
|
|
55
|
-
request("http://example.org/cookies/count").should have_body("1")
|
|
56
|
-
request("http://www.example.org/cookies/count").should have_body("1")
|
|
57
|
-
request("http://example.org/cookies/count").should have_body("2")
|
|
58
|
-
request("http://www.example.org/cookies/count").should have_body("2")
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "treats domains case insensitively" do
|
|
62
|
-
get "http://example.com/cookies/set", "value" => "1"
|
|
63
|
-
get "http://EXAMPLE.COM/cookies/show"
|
|
64
|
-
last_request.cookies.should == { "value" => "1" }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "treats paths case sensitively" do
|
|
68
|
-
get "/cookies/set", "value" => "1"
|
|
69
|
-
get "/COOKIES/show"
|
|
70
|
-
last_request.cookies.should == {}
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "prefers more specific cookies" do
|
|
74
|
-
get "http://example.com/cookies/set", "value" => "domain"
|
|
75
|
-
get "http://sub.example.com/cookies/set", "value" => "sub"
|
|
76
|
-
|
|
77
|
-
get "http://sub.example.com/cookies/show"
|
|
78
|
-
last_request.cookies.should == { "value" => "sub" }
|
|
79
|
-
|
|
80
|
-
get "http://example.com/cookies/show"
|
|
81
|
-
last_request.cookies.should == { "value" => "domain" }
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "treats cookie names case insensitively" do
|
|
85
|
-
get "/cookies/set", "value" => "lowercase"
|
|
86
|
-
get "/cookies/set-uppercase", "value" => "UPPERCASE"
|
|
87
|
-
get "/cookies/show"
|
|
88
|
-
last_request.cookies.should == { "VALUE" => "UPPERCASE" }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "defaults the domain to the request domain" do
|
|
92
|
-
get "http://example.com/cookies/set-simple", "value" => "cookie"
|
|
93
|
-
get "http://example.com/cookies/show"
|
|
94
|
-
last_request.cookies.should == { "simple" => "cookie" }
|
|
95
|
-
|
|
96
|
-
get "http://other.example/cookies/show"
|
|
97
|
-
last_request.cookies.should == {}
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "defaults the domain to the request path up to the last slash" do
|
|
101
|
-
get "/cookies/set-simple", "value" => "1"
|
|
102
|
-
get "/not-cookies/show"
|
|
103
|
-
last_request.cookies.should == {}
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "supports secure cookies" do
|
|
107
|
-
get "https://example.com/cookies/set-secure", "value" => "set"
|
|
108
|
-
get "http://example.com/cookies/show"
|
|
109
|
-
last_request.cookies.should == {}
|
|
110
|
-
|
|
111
|
-
get "https://example.com/cookies/show"
|
|
112
|
-
last_request.cookies.should == { "secure-cookie" => "set" }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "keeps separate cookie jars for different domains" do
|
|
116
|
-
get "http://example.com/cookies/set", "value" => "example"
|
|
117
|
-
get "http://example.com/cookies/show"
|
|
118
|
-
last_request.cookies.should == { "value" => "example" }
|
|
119
|
-
|
|
120
|
-
get "http://other.example/cookies/set", "value" => "other"
|
|
121
|
-
get "http://other.example/cookies/show"
|
|
122
|
-
last_request.cookies.should == { "value" => "other" }
|
|
123
|
-
|
|
124
|
-
get "http://example.com/cookies/show"
|
|
125
|
-
last_request.cookies.should == { "value" => "example" }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "allows cookies to be cleared" do
|
|
129
|
-
get "/cookies/set", "value" => "1"
|
|
130
|
-
clear_cookies
|
|
131
|
-
get "/cookies/show"
|
|
132
|
-
last_request.cookies.should == {}
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "allow cookies to be set" do
|
|
136
|
-
set_cookie "value=10"
|
|
137
|
-
get "/cookies/show"
|
|
138
|
-
last_request.cookies.should == { "value" => "10" }
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "allows an array of cookies to be set" do
|
|
142
|
-
set_cookie ["value=10", "foo=bar"]
|
|
143
|
-
get "/cookies/show"
|
|
144
|
-
last_request.cookies.should == { "value" => "10", "foo" => "bar" }
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it "supports multiple sessions" do
|
|
148
|
-
with_session(:first) do
|
|
149
|
-
get "/cookies/set", "value" => "1"
|
|
150
|
-
get "/cookies/show"
|
|
151
|
-
last_request.cookies.should == { "value" => "1" }
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
with_session(:second) do
|
|
155
|
-
get "/cookies/show"
|
|
156
|
-
last_request.cookies.should == { }
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "uses :default as the default session name" do
|
|
161
|
-
get "/cookies/set", "value" => "1"
|
|
162
|
-
get "/cookies/show"
|
|
163
|
-
last_request.cookies.should == { "value" => "1" }
|
|
164
|
-
|
|
165
|
-
with_session(:default) do
|
|
166
|
-
get "/cookies/show"
|
|
167
|
-
last_request.cookies.should == { "value" => "1" }
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
it "accepts explicitly provided cookies" do
|
|
172
|
-
request "/cookies/show", :cookie => "value=1"
|
|
173
|
-
last_request.cookies.should == { "value" => "1" }
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
end
|