Sha256: 3f6ee813e1efc28467700089e4ca018dfe408a8f4522de94e5db6185d2de7896

Contents?: true

Size: 733 Bytes

Versions: 9

Compression:

Stored size: 733 Bytes

Contents

require 'rack/static'
require 'rack/mock'

class DummyApp
  def call(env)
    [200, {}, ["Hello World"]]
  end
end

describe Rack::Static do
  root = File.expand_path(File.dirname(__FILE__))
  OPTIONS = {:urls => ["/cgi"], :root => root}

  @request = Rack::MockRequest.new(Rack::Static.new(DummyApp.new, OPTIONS))

  it "serves files" do
    res = @request.get("/cgi/test")
    res.should.be.ok
    res.body.should =~ /ruby/
  end

  it "404s if url root is known but it can't find the file" do
    res = @request.get("/cgi/foo")
    res.should.be.not_found
  end

  it "calls down the chain if url root is not known" do
    res = @request.get("/something/else")
    res.should.be.ok
    res.body.should == "Hello World"
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rack-1.2.8 test/spec_static.rb
rack-1.2.7 test/spec_static.rb
rack-1.2.6 test/spec_static.rb
rack-1.2.5 test/spec_static.rb
rack-1.2.4 test/spec_static.rb
rack-1.2.3 test/spec_static.rb
rack-1.2.2 test/spec_static.rb
rack-1.2.1 test/spec_static.rb
rack-1.2.0 spec/spec_static.rb