Skip to content
This repository
tree: d9195d7e1e
Fetching contributors…

Cannot retrieve contributors at this time

file 26 lines (23 sloc) 0.743 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
require 'test/unit'
require 'rack/mock'
require 'shotgun'

class ShotgunStaticTest < Test::Unit::TestCase
  def setup
    @app = lambda { |env| [200,{'Content-Type'=>'text/plain'}, ['holla']] }
    @public = File.dirname(__FILE__)
  end

  def test_serving_files
    static = Shotgun::Static.new(@app, @public)
    request = Rack::MockRequest.new(static)
    res = request.get("/big.ru")
    assert_equal 200, res.status
    assert_equal File.size("#{@public}/big.ru"), res.body.size
  end

  def test_cascading_when_file_not_found
    static = Shotgun::Static.new(@app, @public)
    request = Rack::MockRequest.new(static)
    res = request.get("/does-not-exist")
    assert_equal 200, res.status
    assert_equal 'holla', res.body
  end
end
Something went wrong with that request. Please try again.