diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2017-05-15 09:50:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-15 09:50:13 -0700 |
commit | d4793a0707efa9011ded6ebc88154ac9d7f98c8a (patch) | |
tree | 31c5619108ff61e7cf98ccf311f1ff0d38ccc361 /test/spec_mock.rb | |
parent | f2dacc6bb881ed1f588eecf00134abca8e26665e (diff) | |
parent | 25ca3e5ebfc761041d3b5f375ad62d507c8dd14f (diff) | |
download | rack-d4793a0707efa9011ded6ebc88154ac9d7f98c8a.tar.gz |
Merge pull request #1163 from janko-m/rely-on-size-in-mock-request
Rely on input responding to #size instead of #length in MockRequest.env_for
Diffstat (limited to 'test/spec_mock.rb')
-rw-r--r-- | test/spec_mock.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/spec_mock.rb b/test/spec_mock.rb index e383f203..c7992321 100644 --- a/test/spec_mock.rb +++ b/test/spec_mock.rb @@ -84,6 +84,15 @@ describe Rack::MockRequest do it "set content length" do env = Rack::MockRequest.env_for("/", :input => "foo") env["CONTENT_LENGTH"].must_equal "3" + + env = Rack::MockRequest.env_for("/", :input => StringIO.new("foo")) + env["CONTENT_LENGTH"].must_equal "3" + + env = Rack::MockRequest.env_for("/", :input => Tempfile.new("name").tap { |t| t << "foo" }) + env["CONTENT_LENGTH"].must_equal "3" + + env = Rack::MockRequest.env_for("/", :input => IO.pipe.first) + env["CONTENT_LENGTH"].must_be_nil end it "allow posting" do |