middleman 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/middleman.gemspec +65 -6
- data/pkg/middleman-0.2.1.gem +0 -0
- data/rdoc/classes/Middleman.html +164 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_rdoc.html +114 -0
- data/rdoc/files/lib/middleman_rb.html +111 -0
- data/rdoc/fr_class_index.html +27 -0
- data/rdoc/fr_file_index.html +28 -0
- data/rdoc/fr_method_index.html +27 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/vendor/rack-test/History.txt +64 -0
- data/vendor/rack-test/MIT-LICENSE.txt +19 -0
- data/vendor/rack-test/README.rdoc +57 -0
- data/vendor/rack-test/Rakefile +62 -0
- data/vendor/rack-test/lib/rack/mock_session.rb +57 -0
- data/vendor/rack-test/lib/rack/test.rb +246 -0
- data/vendor/rack-test/lib/rack/test/cookie_jar.rb +169 -0
- data/vendor/rack-test/lib/rack/test/methods.rb +73 -0
- data/vendor/rack-test/lib/rack/test/mock_digest_request.rb +27 -0
- data/vendor/rack-test/lib/rack/test/uploaded_file.rb +36 -0
- data/vendor/rack-test/lib/rack/test/utils.rb +75 -0
- data/vendor/rack-test/spec/fixtures/config.ru +3 -0
- data/vendor/rack-test/spec/fixtures/fake_app.rb +109 -0
- data/vendor/rack-test/spec/fixtures/foo.txt +1 -0
- data/vendor/rack-test/spec/rack/test/cookie_spec.rb +176 -0
- data/vendor/rack-test/spec/rack/test/digest_auth_spec.rb +48 -0
- data/vendor/rack-test/spec/rack/test/multipart_spec.rb +85 -0
- data/vendor/rack-test/spec/rack/test/utils_spec.rb +44 -0
- data/vendor/rack-test/spec/rack/test_spec.rb +363 -0
- data/vendor/rack-test/spec/rcov.opts +1 -0
- data/vendor/rack-test/spec/spec.opts +1 -0
- data/vendor/rack-test/spec/spec_helper.rb +48 -0
- data/vendor/sinatra-markaby/CHANGES +7 -0
- data/vendor/sinatra-markaby/LICENSE +20 -0
- data/vendor/sinatra-markaby/README.rdoc +33 -0
- data/vendor/sinatra-markaby/Rakefile +45 -0
- data/vendor/sinatra-markaby/TODO +3 -0
- data/vendor/sinatra-markaby/VERSION.yml +4 -0
- data/vendor/sinatra-markaby/lib/sinatra/markaby.rb +31 -0
- data/vendor/sinatra-markaby/sinatra-markaby.gemspec +49 -0
- data/vendor/sinatra-markaby/test/sinatra_markaby_test.rb +72 -0
- data/vendor/sinatra-markaby/test/test_helper.rb +19 -0
- data/vendor/sinatra-markaby/test/views/hello.mab +1 -0
- data/vendor/sinatra-markaby/test/views/html.mab +4 -0
- data/vendor/sinatra-maruku/LICENSE +22 -0
- data/vendor/sinatra-maruku/README.markdown +85 -0
- data/vendor/sinatra-maruku/Rakefile +34 -0
- data/vendor/sinatra-maruku/VERSION.yml +4 -0
- data/vendor/sinatra-maruku/examples/app.rb +8 -0
- data/vendor/sinatra-maruku/examples/config.ru +4 -0
- data/vendor/sinatra-maruku/examples/mapp.rb +15 -0
- data/vendor/sinatra-maruku/examples/public/javascripts/application.js +0 -0
- data/vendor/sinatra-maruku/examples/public/stylesheets/application.css +23 -0
- data/vendor/sinatra-maruku/examples/public/stylesheets/print.css +0 -0
- data/vendor/sinatra-maruku/examples/views/index.maruku +32 -0
- data/vendor/sinatra-maruku/examples/views/layout.maruku +9 -0
- data/vendor/sinatra-maruku/lib/sinatra/maruku.rb +25 -0
- data/vendor/sinatra-maruku/sinatra-maruku.gemspec +70 -0
- data/vendor/sinatra-maruku/test/sinatra_maruku_test.rb +91 -0
- data/vendor/sinatra-maruku/test/test_helper.rb +21 -0
- data/vendor/sinatra-maruku/test/views/hello.maruku +1 -0
- data/vendor/sinatra-maruku/test/views/layout2.maruku +2 -0
- metadata +63 -4
- data/.document +0 -5
- data/.gitignore +0 -6
- data/.gitmodules +0 -9
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
|
+
|
3
|
+
describe Rack::Test::Session do
|
4
|
+
context "HTTP Digest authentication" do
|
5
|
+
|
6
|
+
def app
|
7
|
+
app = Rack::Auth::Digest::MD5.new(Rack::Test::FakeApp.new) do |username|
|
8
|
+
{ 'alice' => 'correct-password' }[username]
|
9
|
+
end
|
10
|
+
app.realm = 'WallysWorld'
|
11
|
+
app.opaque = 'this-should-be-secret'
|
12
|
+
app
|
13
|
+
end
|
14
|
+
|
15
|
+
def be_challenge
|
16
|
+
simple_matcher "a HTTP Digest challenge response" do |response|
|
17
|
+
response.status == 401 &&
|
18
|
+
response['WWW-Authenticate'] =~ /^Digest / &&
|
19
|
+
response.body.empty?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'incorrectly authenticates GETs' do
|
24
|
+
digest_authorize 'foo', 'bar'
|
25
|
+
get '/'
|
26
|
+
last_response.should be_challenge
|
27
|
+
end
|
28
|
+
|
29
|
+
it "correctly authenticates GETs" do
|
30
|
+
digest_authorize "alice", "correct-password"
|
31
|
+
response = get "/"
|
32
|
+
response.should be_ok
|
33
|
+
end
|
34
|
+
|
35
|
+
it "correctly authenticates POSTs" do
|
36
|
+
digest_authorize "alice", "correct-password"
|
37
|
+
response = post "/"
|
38
|
+
response.should be_ok
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns a re-challenge if authenticating incorrectly" do
|
42
|
+
digest_authorize "alice", "incorrect-password"
|
43
|
+
response = get "/"
|
44
|
+
response.should be_challenge
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
|
+
|
3
|
+
describe Rack::Test::Session do
|
4
|
+
|
5
|
+
def test_file_path
|
6
|
+
File.dirname(__FILE__) + "/../../fixtures/foo.txt"
|
7
|
+
end
|
8
|
+
|
9
|
+
def uploaded_file
|
10
|
+
Rack::Test::UploadedFile.new(test_file_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "uploading a file" do
|
14
|
+
it "sends the multipart/form-data content type" do
|
15
|
+
post "/", "photo" => uploaded_file
|
16
|
+
last_request.env["CONTENT_TYPE"].should include("multipart/form-data;")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "sends regular params" do
|
20
|
+
post "/", "photo" => uploaded_file, "foo" => "bar"
|
21
|
+
last_request.POST["foo"].should == "bar"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sends nested params" do
|
25
|
+
post "/", "photo" => uploaded_file, "foo" => {"bar" => "baz"}
|
26
|
+
last_request.POST["foo"]["bar"].should == "baz"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "sends multiple nested params" do
|
30
|
+
post "/", "photo" => uploaded_file, "foo" => {"bar" => {"baz" => "bop"}}
|
31
|
+
last_request.POST["foo"]["bar"]["baz"].should == "bop"
|
32
|
+
end
|
33
|
+
|
34
|
+
xit "sends params with arrays" do
|
35
|
+
post "/", "photo" => uploaded_file, "foo" => ["1", "2"]
|
36
|
+
last_request.POST["foo[]"].should == ["1", "2"]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "sends params with encoding sensitive values" do
|
40
|
+
post "/", "photo" => uploaded_file, "foo" => "bar? baz"
|
41
|
+
last_request.POST["foo"].should == "bar? baz"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "sends params with parens in names" do
|
45
|
+
post "/", "photo" => uploaded_file, "foo(1i)" => "bar"
|
46
|
+
last_request.POST["foo(1i)"].should == "bar"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "sends params with encoding sensitive names" do
|
50
|
+
post "/", "photo" => uploaded_file, "foo bar" => "baz"
|
51
|
+
last_request.POST["foo bar"].should == "baz"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sends files with the filename" do
|
55
|
+
post "/", "photo" => uploaded_file
|
56
|
+
last_request.POST["photo"][:filename].should == "foo.txt"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "sends files with the text/plain MIME type by default" do
|
60
|
+
post "/", "photo" => uploaded_file
|
61
|
+
last_request.POST["photo"][:type].should == "text/plain"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "sends files with the right name" do
|
65
|
+
post "/", "photo" => uploaded_file
|
66
|
+
last_request.POST["photo"][:name].should == "photo"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "allows overriding the content type" do
|
70
|
+
post "/", "photo" => Rack::Test::UploadedFile.new(test_file_path, "image/jpeg")
|
71
|
+
last_request.POST["photo"][:type].should == "image/jpeg"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "sends files with a Content-Length in the header" do
|
75
|
+
post "/", "photo" => uploaded_file
|
76
|
+
last_request.POST["photo"][:head].should include("Content-Length: 4")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "sends files as Tempfiles" do
|
80
|
+
post "/", "photo" => uploaded_file
|
81
|
+
last_request.POST["photo"][:tempfile].should be_a(::Tempfile)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
|
+
|
3
|
+
describe Rack::Test::Utils do
|
4
|
+
include Rack::Test::Utils
|
5
|
+
|
6
|
+
describe "requestify" do
|
7
|
+
it "converts empty strings to =" do
|
8
|
+
requestify("").should == "="
|
9
|
+
end
|
10
|
+
|
11
|
+
it "converts nil to =" do
|
12
|
+
requestify(nil).should == "="
|
13
|
+
end
|
14
|
+
|
15
|
+
it "converts hashes" do
|
16
|
+
requestify(:a => 1).should == "a=1"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "converts hashes with multiple keys" do
|
20
|
+
hash = { :a => 1, :b => 2 }
|
21
|
+
["a=1&b=2", "b=2&a=1"].should include(requestify(hash))
|
22
|
+
end
|
23
|
+
|
24
|
+
it "converts arrays with one element" do
|
25
|
+
requestify(:a => [1]).should == "a[]=1"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "converts arrays with multiple elements" do
|
29
|
+
requestify(:a => [1, 2]).should == "a[]=1&a[]=2"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "converts nested hashes" do
|
33
|
+
requestify(:a => { :b => 1 }).should == "a[b]=1"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "converts arrays nested in a hash" do
|
37
|
+
requestify(:a => { :b => [1, 2] }).should == "a[b][]=1&a[b][]=2"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "converts arrays of hashes" do
|
41
|
+
requestify(:a => [{ :b => 2}, { :c => 3}]).should == "a[][b]=2&a[][c]=3"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe Rack::Test::Session do
|
4
|
+
describe "initialization" do
|
5
|
+
it "supports being initialized with a Rack::MockSession app" do
|
6
|
+
session = Rack::Test::Session.new(Rack::MockSession.new(app))
|
7
|
+
session.request("/").should be_ok
|
8
|
+
end
|
9
|
+
|
10
|
+
it "supports being initialized with an app" do
|
11
|
+
session = Rack::Test::Session.new(app)
|
12
|
+
session.request("/").should be_ok
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#request" do
|
17
|
+
it "requests the URI using GET by default" do
|
18
|
+
request "/"
|
19
|
+
last_request.should be_get
|
20
|
+
last_response.should be_ok
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a response" do
|
24
|
+
request("/").should be_ok
|
25
|
+
end
|
26
|
+
|
27
|
+
it "uses the provided env" do
|
28
|
+
request "/", "X-Foo" => "bar"
|
29
|
+
last_request.env["X-Foo"].should == "bar"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "defaults to GET" do
|
33
|
+
request "/"
|
34
|
+
last_request.env["REQUEST_METHOD"].should == "GET"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "defaults the REMOTE_ADDR to 127.0.0.1" do
|
38
|
+
request "/"
|
39
|
+
last_request.env["REMOTE_ADDR"].should == "127.0.0.1"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "sets rack.test to true in the env" do
|
43
|
+
request "/"
|
44
|
+
last_request.env["rack.test"].should == true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "defaults to port 80" do
|
48
|
+
request "/"
|
49
|
+
last_request.env["SERVER_PORT"].should == "80"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "defaults to example.org" do
|
53
|
+
request "/"
|
54
|
+
last_request.env["SERVER_NAME"].should == "example.org"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "yields the response to a given block" do
|
58
|
+
request "/" do |response|
|
59
|
+
response.should be_ok
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "supports sending :params" do
|
64
|
+
request "/", :params => { "foo" => "bar" }
|
65
|
+
last_request.GET["foo"].should == "bar"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "doesn't follow redirects by default" do
|
69
|
+
request "/redirect"
|
70
|
+
last_response.should be_redirect
|
71
|
+
last_response.body.should be_empty
|
72
|
+
end
|
73
|
+
|
74
|
+
context "when input is given" do
|
75
|
+
it "should send the input" do
|
76
|
+
request "/", :method => "POST", :input => "foo"
|
77
|
+
last_request.env["rack.input"].read.should == "foo"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not send a multipart request" do
|
81
|
+
request "/", :method => "POST", :input => "foo"
|
82
|
+
last_request.env["CONTENT_TYPE"].should_not == "application/x-www-form-urlencoded"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "for a POST specified with :method" do
|
87
|
+
it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do
|
88
|
+
request "/", :method => "POST"
|
89
|
+
last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "for a POST specified with REQUEST_METHOD" do
|
94
|
+
it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do
|
95
|
+
request "/", "REQUEST_METHOD" => "POST"
|
96
|
+
last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when CONTENT_TYPE is specified in the env" do
|
101
|
+
it "does not overwrite the CONTENT_TYPE" do
|
102
|
+
request "/", "CONTENT_TYPE" => "application/xml"
|
103
|
+
last_request.env["CONTENT_TYPE"].should == "application/xml"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when the URL is https://" do
|
108
|
+
it "sets SERVER_PORT to 443" do
|
109
|
+
get "https://example.org/"
|
110
|
+
last_request.env["SERVER_PORT"].should == "443"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "sets HTTPS to on" do
|
114
|
+
get "https://example.org/"
|
115
|
+
last_request.env["HTTPS"].should == "on"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "for a XHR" do
|
120
|
+
it "sends XMLHttpRequest for the X-Requested-With header" do
|
121
|
+
request "/", :xhr => true
|
122
|
+
last_request.env["X-Requested-With"].should == "XMLHttpRequest"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#header" do
|
128
|
+
it "sets a header to be sent with requests" do
|
129
|
+
header "User-Agent", "Firefox"
|
130
|
+
request "/"
|
131
|
+
|
132
|
+
last_request.env["User-Agent"].should == "Firefox"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "persists across multiple requests" do
|
136
|
+
header "User-Agent", "Firefox"
|
137
|
+
request "/"
|
138
|
+
request "/"
|
139
|
+
|
140
|
+
last_request.env["User-Agent"].should == "Firefox"
|
141
|
+
end
|
142
|
+
|
143
|
+
it "overwrites previously set headers" do
|
144
|
+
header "User-Agent", "Firefox"
|
145
|
+
header "User-Agent", "Safari"
|
146
|
+
request "/"
|
147
|
+
|
148
|
+
last_request.env["User-Agent"].should == "Safari"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "can be used to clear a header" do
|
152
|
+
header "User-Agent", "Firefox"
|
153
|
+
header "User-Agent", nil
|
154
|
+
request "/"
|
155
|
+
|
156
|
+
last_request.env.should_not have_key("User-Agent")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "is overridden by headers sent during the request" do
|
160
|
+
header "User-Agent", "Firefox"
|
161
|
+
request "/", "User-Agent" => "Safari"
|
162
|
+
|
163
|
+
last_request.env["User-Agent"].should == "Safari"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#authorize" do
|
168
|
+
it "sets the HTTP_AUTHORIZATION header" do
|
169
|
+
authorize "bryan", "secret"
|
170
|
+
request "/"
|
171
|
+
|
172
|
+
last_request.env["HTTP_AUTHORIZATION"].should == "Basic YnJ5YW46c2VjcmV0\n"
|
173
|
+
end
|
174
|
+
|
175
|
+
it "includes the header for subsequent requests" do
|
176
|
+
basic_authorize "bryan", "secret"
|
177
|
+
request "/"
|
178
|
+
request "/"
|
179
|
+
|
180
|
+
last_request.env["HTTP_AUTHORIZATION"].should == "Basic YnJ5YW46c2VjcmV0\n"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "follow_redirect!" do
|
185
|
+
it "follows redirects" do
|
186
|
+
get "/redirect"
|
187
|
+
follow_redirect!
|
188
|
+
|
189
|
+
last_response.should_not be_redirect
|
190
|
+
last_response.body.should == "You've been redirected"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "does not include params when following the redirect" do
|
194
|
+
get "/redirect", { "foo" => "bar" }
|
195
|
+
follow_redirect!
|
196
|
+
|
197
|
+
last_request.GET.should == {}
|
198
|
+
end
|
199
|
+
|
200
|
+
it "raises an error if the last_response is not set" do
|
201
|
+
lambda {
|
202
|
+
follow_redirect!
|
203
|
+
}.should raise_error(Rack::Test::Error)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "raises an error if the last_response is not a redirect" do
|
207
|
+
get "/"
|
208
|
+
|
209
|
+
lambda {
|
210
|
+
follow_redirect!
|
211
|
+
}.should raise_error(Rack::Test::Error)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe "#last_request" do
|
216
|
+
it "returns the most recent request" do
|
217
|
+
request "/"
|
218
|
+
last_request.env["PATH_INFO"].should == "/"
|
219
|
+
end
|
220
|
+
|
221
|
+
it "raises an error if no requests have been issued" do
|
222
|
+
lambda {
|
223
|
+
last_request
|
224
|
+
}.should raise_error(Rack::Test::Error)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "#last_response" do
|
229
|
+
it "returns the most recent response" do
|
230
|
+
request "/"
|
231
|
+
last_response["Content-Type"].should == "text/html"
|
232
|
+
end
|
233
|
+
|
234
|
+
it "raises an error if no requests have been issued" do
|
235
|
+
lambda {
|
236
|
+
last_response
|
237
|
+
}.should raise_error
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "after_request" do
|
242
|
+
it "runs callbacks after each request" do
|
243
|
+
ran = false
|
244
|
+
|
245
|
+
rack_mock_session.after_request do
|
246
|
+
ran = true
|
247
|
+
end
|
248
|
+
|
249
|
+
get "/"
|
250
|
+
ran.should == true
|
251
|
+
end
|
252
|
+
|
253
|
+
it "runs multiple callbacks" do
|
254
|
+
count = 0
|
255
|
+
|
256
|
+
2.times do
|
257
|
+
rack_mock_session.after_request do
|
258
|
+
count += 1
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
get "/"
|
263
|
+
count.should == 2
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
describe "#get" do
|
268
|
+
it_should_behave_like "any #verb methods"
|
269
|
+
|
270
|
+
def verb
|
271
|
+
"get"
|
272
|
+
end
|
273
|
+
|
274
|
+
it "uses the provided params hash" do
|
275
|
+
get "/", :foo => "bar"
|
276
|
+
last_request.GET.should == { "foo" => "bar" }
|
277
|
+
end
|
278
|
+
|
279
|
+
it "sends params with parens in names" do
|
280
|
+
get "/", "foo(1i)" => "bar"
|
281
|
+
last_request.GET["foo(1i)"].should == "bar"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "supports params with encoding sensitive names" do
|
285
|
+
get "/", "foo bar" => "baz"
|
286
|
+
last_request.GET["foo bar"].should == "baz"
|
287
|
+
end
|
288
|
+
|
289
|
+
it "supports params with nested encoding sensitive names" do
|
290
|
+
get "/", "boo" => {"foo bar" => "baz"}
|
291
|
+
last_request.GET.should == {"boo" => {"foo bar" => "baz"}}
|
292
|
+
end
|
293
|
+
|
294
|
+
it "accepts params in the path" do
|
295
|
+
get "/?foo=bar"
|
296
|
+
last_request.GET.should == { "foo" => "bar" }
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
describe "#head" do
|
301
|
+
it_should_behave_like "any #verb methods"
|
302
|
+
|
303
|
+
def verb
|
304
|
+
"head"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "#post" do
|
309
|
+
it_should_behave_like "any #verb methods"
|
310
|
+
|
311
|
+
def verb
|
312
|
+
"post"
|
313
|
+
end
|
314
|
+
|
315
|
+
it "uses the provided params hash" do
|
316
|
+
post "/", :foo => "bar"
|
317
|
+
last_request.POST.should == { "foo" => "bar" }
|
318
|
+
end
|
319
|
+
|
320
|
+
it "supports params with encoding sensitive names" do
|
321
|
+
post "/", "foo bar" => "baz"
|
322
|
+
last_request.POST["foo bar"].should == "baz"
|
323
|
+
end
|
324
|
+
|
325
|
+
it "uses application/x-www-form-urlencoded as the CONTENT_TYPE" do
|
326
|
+
post "/"
|
327
|
+
last_request.env["CONTENT_TYPE"].should == "application/x-www-form-urlencoded"
|
328
|
+
end
|
329
|
+
|
330
|
+
it "accepts a body" do
|
331
|
+
post "/", "Lobsterlicious!"
|
332
|
+
last_request.body.read.should == "Lobsterlicious!"
|
333
|
+
end
|
334
|
+
|
335
|
+
context "when CONTENT_TYPE is specified in the env" do
|
336
|
+
it "does not overwrite the CONTENT_TYPE" do
|
337
|
+
post "/", {}, { "CONTENT_TYPE" => "application/xml" }
|
338
|
+
last_request.env["CONTENT_TYPE"].should == "application/xml"
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe "#put" do
|
344
|
+
it_should_behave_like "any #verb methods"
|
345
|
+
|
346
|
+
def verb
|
347
|
+
"put"
|
348
|
+
end
|
349
|
+
|
350
|
+
it "accepts a body" do
|
351
|
+
put "/", "Lobsterlicious!"
|
352
|
+
last_request.body.read.should == "Lobsterlicious!"
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
describe "#delete" do
|
357
|
+
it_should_behave_like "any #verb methods"
|
358
|
+
|
359
|
+
def verb
|
360
|
+
"delete"
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|