diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb index 4ed835282..5f0e531c0 100644 --- a/lib/rack/mock.rb +++ b/lib/rack/mock.rb @@ -32,6 +32,10 @@ def write(warning) def flush end + + def string + "" + end end DEFAULT_ENV = { diff --git a/test/spec_rack_camping.rb b/test/spec_rack_camping.rb index 9468b365a..be798e302 100644 --- a/test/spec_rack_camping.rb +++ b/test/spec_rack_camping.rb @@ -1,5 +1,6 @@ require 'test/spec' require 'stringio' +require 'uri' require 'rack/mock' @@ -12,6 +13,7 @@ module CampApp module Controllers class HW < R('/') def get + @headers["X-Served-By"] = URI("http://rack.rubyforge.org") "Camping works!" end @@ -30,6 +32,7 @@ def post res.should.be.ok res["Content-Type"].should.equal "text/html" + res["X-Served-By"].should.equal "http://rack.rubyforge.org" res.body.should.equal "Camping works!" end diff --git a/test/spec_rack_mock.rb b/test/spec_rack_mock.rb index eb017539a..c487bd080 100644 --- a/test/spec_rack_mock.rb +++ b/test/spec_rack_mock.rb @@ -126,6 +126,7 @@ res["Content-Type"].should.equal "text/yaml" res.content_type.should.equal "text/yaml" res.content_length.should.be.nil + res.location.should.be.nil end specify "should provide access to the HTTP body" do @@ -133,6 +134,7 @@ res.body.should =~ /rack/ res.should =~ /rack/ res.should.match(/rack/) + res.should.satisfy { |r| r.match(/rack/) } end specify "should provide access to the Rack errors" do diff --git a/test/spec_rack_session_cookie.rb b/test/spec_rack_session_cookie.rb index a05cfe2be..96be4ad6a 100644 --- a/test/spec_rack_session_cookie.rb +++ b/test/spec_rack_session_cookie.rb @@ -34,4 +34,16 @@ get("/", "HTTP_COOKIE" => "rack.session=blarghfasel") res.body.should.equal '{"counter"=>1}' end + + bigcookie = lambda { |env| + env["rack.session"]["cookie"] = "big" * 3000 + Rack::Response.new(env["rack.session"].inspect).to_a + } + + specify "barks on too big cookies" do + lambda { + Rack::MockRequest.new(Rack::Session::Cookie.new(bigcookie)). + get("/", :fatal => true) + }.should.raise(Rack::MockRequest::FatalWarning) + end end diff --git a/test/spec_rack_urlmap.rb b/test/spec_rack_urlmap.rb index 3e35f90ec..3d172edb5 100644 --- a/test/spec_rack_urlmap.rb +++ b/test/spec_rack_urlmap.rb @@ -17,14 +17,8 @@ { "Content-Type" => "text/plain", "X-Position" => "/bar", "X-PathInfo" => env["PATH_INFO"], - }, [""]]}, - - "/foo/bar" => lambda { |env| - [200, - { "Content-Type" => "text/plain", - "X-Position" => "/foo/bar", - "X-PathInfo" => env["PATH_INFO"], }, [""]]} + )