rack-test 0.6.3 → 0.8.0

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.
@@ -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
@@ -1,46 +0,0 @@
1
- require "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
- it 'incorrectly authenticates GETs' do
16
- digest_authorize 'foo', 'bar'
17
- get '/'
18
- last_response.should be_challenge
19
- end
20
-
21
- it "correctly authenticates GETs" do
22
- digest_authorize "alice", "correct-password"
23
- response = get "/"
24
- response.should be_ok
25
- end
26
-
27
- it "correctly authenticates GETs with params" do
28
- digest_authorize "alice", "correct-password"
29
- response = get "/", "foo" => "bar"
30
- response.should be_ok
31
- end
32
-
33
- it "correctly authenticates POSTs" do
34
- digest_authorize "alice", "correct-password"
35
- response = post "/"
36
- response.should be_ok
37
- end
38
-
39
- it "returns a re-challenge if authenticating incorrectly" do
40
- digest_authorize "alice", "incorrect-password"
41
- response = get "/"
42
- response.should be_challenge
43
- end
44
-
45
- end
46
- end
@@ -1,145 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require "spec_helper"
4
-
5
- describe Rack::Test::Session do
6
-
7
- def test_file_path
8
- File.dirname(__FILE__) + "/../../fixtures/foo.txt"
9
- end
10
-
11
- def second_test_file_path
12
- File.dirname(__FILE__) + "/../../fixtures/bar.txt"
13
- end
14
-
15
- def uploaded_file
16
- Rack::Test::UploadedFile.new(test_file_path)
17
- end
18
-
19
- def second_uploaded_file
20
- Rack::Test::UploadedFile.new(second_test_file_path)
21
- end
22
-
23
- context "uploading a file" do
24
- it "sends the multipart/form-data content type" do
25
- post "/", "photo" => uploaded_file
26
- last_request.env["CONTENT_TYPE"].should include("multipart/form-data;")
27
- end
28
-
29
- it "sends regular params" do
30
- post "/", "photo" => uploaded_file, "foo" => "bar"
31
- last_request.POST["foo"].should == "bar"
32
- end
33
-
34
- it "sends nested params" do
35
- post "/", "photo" => uploaded_file, "foo" => {"bar" => "baz"}
36
- last_request.POST["foo"]["bar"].should == "baz"
37
- end
38
-
39
- it "sends multiple nested params" do
40
- post "/", "photo" => uploaded_file, "foo" => {"bar" => {"baz" => "bop"}}
41
- last_request.POST["foo"]["bar"]["baz"].should == "bop"
42
- end
43
-
44
- it "sends params with arrays" do
45
- post "/", "photo" => uploaded_file, "foo" => ["1", "2"]
46
- last_request.POST["foo"].should == ["1", "2"]
47
- end
48
-
49
- it "sends params with encoding sensitive values" do
50
- post "/", "photo" => uploaded_file, "foo" => "bar? baz"
51
- last_request.POST["foo"].should == "bar? baz"
52
- end
53
-
54
- it "sends params encoded as ISO-8859-1" do
55
- post "/", "photo" => uploaded_file, "foo" => "bar", "utf8" => "☃"
56
- last_request.POST["foo"].should == "bar"
57
-
58
- if Rack::Test.encoding_aware_strings?
59
- last_request.POST["utf8"].should == "☃"
60
- else
61
- last_request.POST["utf8"].should == "\xE2\x98\x83"
62
- end
63
- end
64
-
65
- it "sends params with parens in names" do
66
- post "/", "photo" => uploaded_file, "foo(1i)" => "bar"
67
- last_request.POST["foo(1i)"].should == "bar"
68
- end
69
-
70
- it "sends params with encoding sensitive names" do
71
- post "/", "photo" => uploaded_file, "foo bar" => "baz"
72
- last_request.POST["foo bar"].should == "baz"
73
- end
74
-
75
- it "sends files with the filename" do
76
- post "/", "photo" => uploaded_file
77
- last_request.POST["photo"][:filename].should == "foo.txt"
78
- end
79
-
80
- it "sends files with the text/plain MIME type by default" do
81
- post "/", "photo" => uploaded_file
82
- last_request.POST["photo"][:type].should == "text/plain"
83
- end
84
-
85
- it "sends files with the right name" do
86
- post "/", "photo" => uploaded_file
87
- last_request.POST["photo"][:name].should == "photo"
88
- end
89
-
90
- it "allows overriding the content type" do
91
- post "/", "photo" => Rack::Test::UploadedFile.new(test_file_path, "image/jpeg")
92
- last_request.POST["photo"][:type].should == "image/jpeg"
93
- end
94
-
95
- it "sends files with a Content-Length in the header" do
96
- post "/", "photo" => uploaded_file
97
- last_request.POST["photo"][:head].should include("Content-Length: 4")
98
- end
99
-
100
- it "sends files as Tempfiles" do
101
- post "/", "photo" => uploaded_file
102
- last_request.POST["photo"][:tempfile].should be_a(::Tempfile)
103
- end
104
- end
105
-
106
-
107
- context "uploading two files" do
108
- it "sends the multipart/form-data content type" do
109
- post "/", "photos" => [uploaded_file, second_uploaded_file]
110
- last_request.env["CONTENT_TYPE"].should include("multipart/form-data;")
111
- end
112
-
113
- it "sends files with the filename" do
114
- post "/", "photos" => [uploaded_file, second_uploaded_file]
115
- last_request.POST["photos"].collect{|photo| photo[:filename]}.should == ["foo.txt", "bar.txt"]
116
- end
117
-
118
- it "sends files with the text/plain MIME type by default" do
119
- post "/", "photos" => [uploaded_file, second_uploaded_file]
120
- last_request.POST["photos"].collect{|photo| photo[:type]}.should == ["text/plain", "text/plain"]
121
- end
122
-
123
- it "sends files with the right names" do
124
- post "/", "photos" => [uploaded_file, second_uploaded_file]
125
- last_request.POST["photos"].all?{|photo| photo[:name].should == "photos[]" }
126
- end
127
-
128
- it "allows mixed content types" do
129
- image_file = Rack::Test::UploadedFile.new(test_file_path, "image/jpeg")
130
-
131
- post "/", "photos" => [uploaded_file, image_file]
132
- last_request.POST["photos"].collect{|photo| photo[:type]}.should == ["text/plain", "image/jpeg"]
133
- end
134
-
135
- it "sends files with a Content-Length in the header" do
136
- post "/", "photos" => [uploaded_file, second_uploaded_file]
137
- last_request.POST["photos"].all?{|photo| photo[:head].should include("Content-Length: 4") }
138
- end
139
-
140
- it "sends both files as Tempfiles" do
141
- post "/", "photos" => [uploaded_file, second_uploaded_file]
142
- last_request.POST["photos"].all?{|photo| photo[:tempfile].should be_a(::Tempfile) }
143
- end
144
- end
145
- end
@@ -1,24 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Rack::Test::UploadedFile do
4
- def test_file_path
5
- File.dirname(__FILE__) + "/../../fixtures/foo.txt"
6
- end
7
-
8
- it "responds to things that Tempfile responds to" do
9
- uploaded_file = Rack::Test::UploadedFile.new(test_file_path)
10
-
11
- uploaded_file.should respond_to(:close)
12
- uploaded_file.should respond_to(:close!)
13
- uploaded_file.should respond_to(:delete)
14
- uploaded_file.should respond_to(:length)
15
- uploaded_file.should respond_to(:open)
16
- uploaded_file.should respond_to(:path)
17
- uploaded_file.should respond_to(:size)
18
- uploaded_file.should respond_to(:unlink)
19
- uploaded_file.should respond_to(:read)
20
- uploaded_file.should respond_to(:original_filename)
21
- uploaded_file.should respond_to(:tempfile) # Allows calls to params[:file].tempfile
22
- end
23
-
24
- end
@@ -1,193 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Rack::Test::Utils do
4
- include Rack::Test::Utils
5
-
6
- describe "build_nested_query" do
7
- it "converts empty strings to =" do
8
- build_nested_query("").should == "="
9
- end
10
-
11
- it "converts nil to an empty string" do
12
- build_nested_query(nil).should == ""
13
- end
14
-
15
- it "converts hashes with nil values" do
16
- build_nested_query(:a => nil).should == "a"
17
- end
18
-
19
- it "converts hashes" do
20
- build_nested_query(:a => 1).should == "a=1"
21
- end
22
-
23
- it "converts hashes with multiple keys" do
24
- hash = { :a => 1, :b => 2 }
25
- ["a=1&b=2", "b=2&a=1"].should include(build_nested_query(hash))
26
- end
27
-
28
- it "converts arrays with one element" do
29
- build_nested_query(:a => [1]).should == "a[]=1"
30
- end
31
-
32
- it "converts arrays with multiple elements" do
33
- build_nested_query(:a => [1, 2]).should == "a[]=1&a[]=2"
34
- end
35
-
36
- it "converts arrays with brackets '[]' in the name" do
37
- build_nested_query("a[]" => [1, 2]).should == "a%5B%5D=1&a%5B%5D=2"
38
- end
39
-
40
- it "converts nested hashes" do
41
- build_nested_query(:a => { :b => 1 }).should == "a[b]=1"
42
- end
43
-
44
- it "converts arrays nested in a hash" do
45
- build_nested_query(:a => { :b => [1, 2] }).should == "a[b][]=1&a[b][]=2"
46
- end
47
-
48
- it "converts arrays of hashes" do
49
- build_nested_query(:a => [{ :b => 2}, { :c => 3}]).should == "a[][b]=2&a[][c]=3"
50
- end
51
- end
52
-
53
- describe "build_multipart" do
54
- it "builds multipart bodies" do
55
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
56
- data = build_multipart("submit-name" => "Larry", "files" => files)
57
-
58
- options = {
59
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
60
- "CONTENT_LENGTH" => data.length.to_s,
61
- :input => StringIO.new(data)
62
- }
63
- env = Rack::MockRequest.env_for("/", options)
64
- params = Rack::Utils::Multipart.parse_multipart(env)
65
- check params["submit-name"].should == "Larry"
66
- check params["files"][:filename].should == "foo.txt"
67
- params["files"][:tempfile].read.should == "bar\n"
68
- end
69
-
70
- it "builds multipart bodies from array of files" do
71
- files = [Rack::Test::UploadedFile.new(multipart_file("foo.txt")), Rack::Test::UploadedFile.new(multipart_file("bar.txt"))]
72
- data = build_multipart("submit-name" => "Larry", "files" => files)
73
-
74
- options = {
75
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
76
- "CONTENT_LENGTH" => data.length.to_s,
77
- :input => StringIO.new(data)
78
- }
79
- env = Rack::MockRequest.env_for("/", options)
80
- params = Rack::Utils::Multipart.parse_multipart(env)
81
- check params["submit-name"].should == "Larry"
82
-
83
- check params["files"][0][:filename].should == "foo.txt"
84
- params["files"][0][:tempfile].read.should == "bar\n"
85
-
86
- check params["files"][1][:filename].should == "bar.txt"
87
- params["files"][1][:tempfile].read.should == "baz\n"
88
- end
89
-
90
- it "builds nested multipart bodies" do
91
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
92
- data = build_multipart("people" => [{"submit-name" => "Larry", "files" => files}], "foo" => ['1', '2'])
93
-
94
- options = {
95
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
96
- "CONTENT_LENGTH" => data.length.to_s,
97
- :input => StringIO.new(data)
98
- }
99
- env = Rack::MockRequest.env_for("/", options)
100
- params = Rack::Utils::Multipart.parse_multipart(env)
101
- check params["people"][0]["submit-name"].should == "Larry"
102
- check params["people"][0]["files"][:filename].should == "foo.txt"
103
- params["people"][0]["files"][:tempfile].read.should == "bar\n"
104
- check params["foo"].should == ["1", "2"]
105
- end
106
-
107
- it "builds nested multipart bodies with an array of hashes" do
108
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
109
- data = build_multipart("files" => files, "foo" => [{"id" => "1", "name" => 'Dave'}, {"id" => "2", "name" => 'Steve'}])
110
-
111
- options = {
112
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
113
- "CONTENT_LENGTH" => data.length.to_s,
114
- :input => StringIO.new(data)
115
- }
116
- env = Rack::MockRequest.env_for("/", options)
117
- params = Rack::Utils::Multipart.parse_multipart(env)
118
- check params["files"][:filename].should == "foo.txt"
119
- params["files"][:tempfile].read.should == "bar\n"
120
- check params["foo"].should == [{"id" => "1", "name" => "Dave"}, {"id" => "2", "name" => "Steve"}]
121
- end
122
-
123
- it "builds nested multipart bodies with arbitrarily nested array of hashes" do
124
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
125
- data = build_multipart("files" => files, "foo" => {"bar" => [{"id" => "1", "name" => 'Dave'},
126
- {"id" => "2", "name" => 'Steve', "qux" => [{"id" => '3', "name" => 'mike'},
127
- {"id" => '4', "name" => 'Joan'}]}]})
128
-
129
- options = {
130
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
131
- "CONTENT_LENGTH" => data.length.to_s,
132
- :input => StringIO.new(data)
133
- }
134
- env = Rack::MockRequest.env_for("/", options)
135
- params = Rack::Utils::Multipart.parse_multipart(env)
136
- check params["files"][:filename].should == "foo.txt"
137
- params["files"][:tempfile].read.should == "bar\n"
138
- check params["foo"].should == {"bar" => [{"id" => "1", "name" => "Dave"},
139
- {"id" => "2", "name" => "Steve", "qux" => [{"id" => '3', "name" => 'mike'},
140
- {"id" => '4', "name" => 'Joan'}]}]}
141
- end
142
-
143
- it 'does not break with params that look nested, but are not' do
144
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
145
- data = build_multipart("foo[]" => "1", "bar[]" => {"qux" => "2"}, "files[]" => files)
146
-
147
- options = {
148
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
149
- "CONTENT_LENGTH" => data.length.to_s,
150
- :input => StringIO.new(data)
151
- }
152
- env = Rack::MockRequest.env_for("/", options)
153
- params = Rack::Utils::Multipart.parse_multipart(env)
154
- check params["files"][0][:filename].should == "foo.txt"
155
- params["files"][0][:tempfile].read.should == "bar\n"
156
- check params["foo"][0].should == "1"
157
- check params["bar"][0].should == {"qux" => "2"}
158
- end
159
-
160
- it 'allows for nested files' do
161
- files = Rack::Test::UploadedFile.new(multipart_file("foo.txt"))
162
- data = build_multipart("foo" => [{"id" => "1", "data" => files},
163
- {"id" => "2", "data" => ["3", "4"]}])
164
-
165
- options = {
166
- "CONTENT_TYPE" => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}",
167
- "CONTENT_LENGTH" => data.length.to_s,
168
- :input => StringIO.new(data)
169
- }
170
- env = Rack::MockRequest.env_for("/", options)
171
- params = Rack::Utils::Multipart.parse_multipart(env)
172
- check params["foo"][0]["id"].should == "1"
173
- check params["foo"][0]["data"][:filename].should == "foo.txt"
174
- params["foo"][0]["data"][:tempfile].read.should == "bar\n"
175
- check params["foo"][1].should == {"id" => "2", "data" => ["3", "4"]}
176
- end
177
-
178
- it "returns nil if no UploadedFiles were used" do
179
- data = build_multipart("people" => [{"submit-name" => "Larry", "files" => "contents"}])
180
- data.should be_nil
181
- end
182
-
183
- it "raises ArgumentErrors if params is not a Hash" do
184
- lambda {
185
- build_multipart("foo=bar")
186
- }.should raise_error(ArgumentError, "value must be a Hash")
187
- end
188
-
189
- def multipart_file(name)
190
- File.join(File.dirname(__FILE__), "..", "..", "fixtures", name.to_s)
191
- end
192
- end
193
- end