Sha256: d93fc54cf8f57e11e325240a054c44718f7e90c8fb406857ee2cba2da264011e
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the MIT license. require File.expand_path('../../../../spec/helper', __FILE__) spec_require 'hpricot' module Ramaze # minimal middleware, no exception handling middleware!(:spec){|m| m.run m.directory(__DIR__('public')) } end describe 'Directory listing' do behaves_like :rack_test @hierarchy = %w[ /test/deep/hierarchy/one.txt /test/deep/hierarchy/two.txt /test/deep/three.txt /test/deep/four.txt /test/five.txt /test/six.txt ] @hierarchy.each do |path| FileUtils.mkdir_p(__DIR__(:public, File.dirname(path))) FileUtils.touch(__DIR__(:public, path)) end Ramaze.map('/', lambda{|env| [404, {}, ['not found']]}) def build_listing(path) get('path').body end def check(url, title, list) got = get(url) got.status.should == 200 got['Content-Type'].should == 'text/html; charset=utf-8' doc = Hpricot(got.body) doc.at(:title).inner_text.should == title (doc/'td.name/a').map{|a| [a[:href], a.inner_text] }.should == list end should 'dry serve root directory' do files = [ ["../", "Parent Directory"], ["/favicon.ico", "favicon.ico"], ["/file+name.txt", "file name.txt"], ["/test/", "test/"], ["/test_download.css", "test_download.css"] ] check '/', '/', files end should 'serve hierarchies' do files = [ ["../", "Parent Directory"], ["/test/deep/", "deep/"], ["/test/five.txt", "five.txt"], ["/test/six.txt", "six.txt"] ] check '/test', '/test', files end FileUtils.rm_rf(__DIR__('public/test')) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ramaze-2012.04.14 | spec/ramaze/dispatcher/directory.rb |
ramaze-2012.03.07 | spec/ramaze/dispatcher/directory.rb |