test/static_test.rb in bmizerany-sinatra-0.9.0.4 vs test/static_test.rb in bmizerany-sinatra-0.9.0.5

- old
+ new

@@ -1,46 +1,44 @@ require File.dirname(__FILE__) + '/helper' describe 'Static' do - F = ::File - before do mock_app { set :static, true - set :public, F.dirname(__FILE__) + set :public, File.dirname(__FILE__) } end it 'serves GET requests for files in the public directory' do - get "/#{F.basename(__FILE__)}" + get "/#{File.basename(__FILE__)}" assert ok? assert_equal File.read(__FILE__), body assert_equal File.size(__FILE__).to_s, response['Content-Length'] assert response.headers.include?('Last-Modified') end it 'produces a body that can be iterated over multiple times' do - env = Rack::MockRequest.env_for("/#{F.basename(__FILE__)}") + env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}") status, headers, body = @app.call(env) buf1, buf2 = [], [] body.each { |part| buf1 << part } body.each { |part| buf2 << part } assert_equal buf1.join, buf2.join assert_equal File.read(__FILE__), buf1.join end it 'serves HEAD requests for files in the public directory' do - head "/#{F.basename(__FILE__)}" + head "/#{File.basename(__FILE__)}" assert ok? assert_equal '', body assert_equal File.size(__FILE__).to_s, response['Content-Length'] assert response.headers.include?('Last-Modified') end it 'serves files in preference to custom routes' do - @app.get("/#{F.basename(__FILE__)}") { 'Hello World' } - get "/#{F.basename(__FILE__)}" + @app.get("/#{File.basename(__FILE__)}") { 'Hello World' } + get "/#{File.basename(__FILE__)}" assert ok? assert body != 'Hello World' end it 'does not serve directories' do @@ -48,16 +46,16 @@ assert not_found? end it 'passes to the next handler when the static option is disabled' do @app.set :static, false - get "/#{F.basename(__FILE__)}" + get "/#{File.basename(__FILE__)}" assert not_found? end it 'passes to the next handler when the public option is nil' do @app.set :public, nil - get "/#{F.basename(__FILE__)}" + get "/#{File.basename(__FILE__)}" assert not_found? end it '404s when a file is not found' do get "/foobarbaz.txt"