Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added specification for Rack::Request memoization.

  • Loading branch information...
commit 552f7b0718ee8cd79c185cd72413690f0da72402 1 parent 3873269
@mtodd mtodd authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/spec_rack_request.rb
View
16 test/spec_rack_request.rb
@@ -433,4 +433,20 @@
res.body.should == '212.212.212.212'
end
+
+ specify "memoizes itself to reduce the cost of repetitive initialization" do
+ env = Rack::MockRequest.env_for("http://example.com:8080/")
+ env['rack.request'].should.be.nil
+
+ req1 = Rack::Request.new(env)
+ env['rack.request'].should.not.be.nil
+ req1.should.equal env['rack.request']
+
+ rack_request_object_id = env['rack.request'].object_id
+
+ req2 = Rack::Request.new(env)
+ env['rack.request'].should.not.be.nil
+ rack_request_object_id.should.be.equal env['rack.request'].object_id
+ req2.should.equal env['rack.request']
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.