summaryrefslogtreecommitdiff
path: root/test/spec_request.rb
diff options
context:
space:
mode:
authorJason Staten <jstaten07@gmail.com>2013-07-18 17:19:32 -0600
committerJason Staten <jstaten07@gmail.com>2013-07-18 17:19:32 -0600
commitb0593078ce792a380779528a6a135c066aa03515 (patch)
tree16a2b6476ba5be7de44fbd79cadd427f331b6fe7 /test/spec_request.rb
parent6829a8a0f416ea49a18f1e3e532ed1ece24e9ea4 (diff)
downloadrack-b0593078ce792a380779528a6a135c066aa03515.tar.gz
Use equal? to compare form_input to rack.input
Using equal? provides consistent results of equality between 1.8, 1.9, and 2.0 when comparing Tempfile objects. In 1.8, == will change the position of the Tempfile. In 1.9+, == compares Tempfiles correctly. In 1.8, eql? compares Tempfiles correctly In 1.9+, t.eql?(t) always returns false
Diffstat (limited to 'test/spec_request.rb')
-rw-r--r--test/spec_request.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/spec_request.rb b/test/spec_request.rb
index 039aae6b..a3f42379 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -878,6 +878,21 @@ EOF
lambda{ req.POST }.should.not.raise("input re-processed!")
end
+ should "use form_hash when form_input is a Tempfile" do
+ input = "{foo: 'bar'}"
+
+ rack_input = Tempfile.new("rackspec")
+ rack_input.write(input)
+ rack_input.rewind
+
+ req = Rack::Request.new Rack::MockRequest.env_for("/",
+ "rack.request.form_hash" => {'foo' => 'bar'},
+ "rack.request.form_input" => rack_input,
+ :input => rack_input)
+
+ req.POST.should.equal(req.env['rack.request.form_hash'])
+ end
+
should "conform to the Rack spec" do
app = lambda { |env|
content = Rack::Request.new(env).POST["file"].inspect