test/spec_file.rb in rack-2.0.1 vs test/spec_file.rb in rack-2.0.2
- old
+ new
@@ -182,12 +182,12 @@
it "support not add custom http headers if none are supplied" do
env = Rack::MockRequest.env_for("/cgi/test")
status, heads, _ = file(DOCROOT).call(env)
status.must_equal 200
- heads['Cache-Control'].must_equal nil
- heads['Access-Control-Allow-Origin'].must_equal nil
+ heads['Cache-Control'].must_be_nil
+ heads['Access-Control-Allow-Origin'].must_be_nil
end
it "only support GET, HEAD, and OPTIONS requests" do
req = Rack::MockRequest.new(file(DOCROOT))
@@ -237,15 +237,28 @@
it "not set Content-Type if the mime type is not set" do
req = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT, nil, nil)))
res = req.get "/cgi/test"
res.must_be :successful?
- res['Content-Type'].must_equal nil
+ res['Content-Type'].must_be_nil
end
it "return error when file not found for head request" do
res = Rack::MockRequest.new(file(DOCROOT)).head("/cgi/missing")
res.must_be :not_found?
res.body.must_be :empty?
+ end
+
+ class MyFile < Rack::File
+ def response_body
+ "hello world"
+ end
+ end
+
+ it "behaves gracefully if response_body is present" do
+ file = Rack::Lint.new MyFile.new(DOCROOT)
+ res = Rack::MockRequest.new(file).get("/cgi/test")
+
+ res.must_be :ok?
end
end