Sha256: 51bde6661c8e503ce069ed8bd1c5ec62bb68e68fc25bc888fea4aca2d9236df1

Contents?: true

Size: 789 Bytes

Versions: 35

Compression:

Stored size: 789 Bytes

Contents

require 'test/spec'

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

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

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

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

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

  specify "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

  specify "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

35 entries across 34 versions & 12 rubygems

Version Path
kjvarga-rack-1.0.0 test/spec_rack_static.rb
qoobaa-rack-1.0.0.1 test/spec_rack_static.rb
qoobaa-rack-1.0.2 test/spec_rack_static.rb
timocratic-rack-1.0.0 test/spec_rack_static.rb
rack-1.1.6 test/spec_rack_static.rb
rack-1.1.5 test/spec_rack_static.rb
rack-1.1.4 test/spec_rack_static.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/test/spec_rack_static.rb
rack-1.1.3 test/spec_rack_static.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/test/spec_rack_static.rb
rack-1.1.2 test/spec_rack_static.rb
rack-1.1.1 test/spec_rack_static.rb
rack-1.1.1.pre test/spec_rack_static.rb
eac-rack-1.1.1 test/spec_rack_static.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_static.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_static.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/rack-1.1.0/test/spec_rack_static.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_static.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_static.rb
rack-1.1.0 test/spec_rack_static.rb