test/spec_file.rb in rack-1.5.5 vs test/spec_file.rb in rack-1.6.0.beta
- old
+ new
@@ -162,25 +162,33 @@
status.should.equal 200
heads['Cache-Control'].should.equal nil
heads['Access-Control-Allow-Origin'].should.equal nil
end
- should "only support GET and HEAD requests" do
+ should "only support GET, HEAD, and OPTIONS requests" do
req = Rack::MockRequest.new(file(DOCROOT))
forbidden = %w[post put patch delete]
forbidden.each do |method|
-
res = req.send(method, "/cgi/test")
res.should.be.client_error
res.should.be.method_not_allowed
+ res.headers['Allow'].split(/, */).sort.should == %w(GET HEAD OPTIONS)
end
- allowed = %w[get head]
+ allowed = %w[get head options]
allowed.each do |method|
res = req.send(method, "/cgi/test")
res.should.be.successful
end
+ end
+
+ should "set Allow correctly for OPTIONS requests" do
+ req = Rack::MockRequest.new(file(DOCROOT))
+ res = req.options('/cgi/test')
+ res.should.be.successful
+ res.headers['Allow'].should.not.equal nil
+ res.headers['Allow'].split(/, */).sort.should == %w(GET HEAD OPTIONS)
end
should "set Content-Length correctly for HEAD requests" do
req = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT)))
res = req.head "/cgi/test"