Sha256: df26aa5a2c7b17ae6c09536c2245b4e8e7a48d90310dfd54444c173fc6a58e5f
Contents?: true
Size: 1.18 KB
Versions: 27
Compression:
Stored size: 1.18 KB
Contents
require 'test/spec' require 'rack/file' require 'rack/lint' require 'rack/mock' context "Rack::File" do DOCROOT = File.expand_path(File.dirname(__FILE__)) specify "serves files" do res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). get("/cgi/test") res.should.be.ok res.should =~ /ruby/ end specify "sets Last-Modified header" do res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). get("/cgi/test") path = File.join(DOCROOT, "/cgi/test") res.should.be.ok res["Last-Modified"].should.equal File.mtime(path).httpdate end specify "serves files with URL encoded filenames" do res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). get("/cgi/%74%65%73%74") # "/cgi/test" res.should.be.ok res.should =~ /ruby/ end specify "does not allow directory traversal" do res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). get("/cgi/../test") res.should.be.forbidden end specify "404s if it can't find the file" do res = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT))). get("/cgi/blubb") res.should.be.not_found end end
Version data entries
27 entries across 27 versions & 5 rubygems