Sha256: 99fa3e37443a69ed6a975c847da3fd8c62c42d75611b639f9fc0b56261217dcd
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
require 'spec/helper' testcase_requires 'hpricot' describe 'Dispatcher::Directory' do before :all do ramaze @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 end def build_listing(path) Ramaze::Dispatcher::Directory.build_listing(path) end it 'should dry serve root directory' do body, status, header = build_listing('/') status.should == 200 header['Content-Type'].should == 'text/html' doc = Hpricot(body) doc.at(:title).inner_text.should == 'Directory listing of /' files = doc.search("//td[@class='n']") links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]} links.should == [["/../", "Parent Directory"], ["/test", "test/"], ["/favicon.ico", "favicon.ico"], ["/test_download.css", "test_download.css"]] end it 'should serve hierarchies' do body, status, header = build_listing('/test') status.should == 200 header['Content-Type'].should == 'text/html' doc = Hpricot(body) doc.at(:title).inner_text.should == 'Directory listing of /test' files = doc.search("//td[@class='n']") links = files.map{|td| a = td.at(:a); [a['href'], a.inner_text]} links.should == [["/test/../", "Parent Directory"], ["/test/deep", "deep/"], ["/test/five.txt", "five.txt"], ["/test/six.txt", "six.txt"]] end after :all do FileUtils.rm_rf(__DIR__/:public/:test) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.2.0 | spec/ramaze/dispatcher/directory.rb |
ramaze-0.2.1 | spec/ramaze/dispatcher/directory.rb |