Sha256: 956efe5b3792a6e2966b8c7a5cdc1217242a679e81647ef7e77338887e6cb2b3
Contents?: true
Size: 1.4 KB
Versions: 7
Compression:
Stored size: 1.4 KB
Contents
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require_relative 'server_helper' require 'zlib' require 'time' class TestExtrasAutoindex < Testcase ENV["N"].to_i > 1 and parallelize_me! include ServerHelper def setup @tmpdir = Dir.mktmpdir server_helper_setup end def teardown server_helper_teardown FileUtils.rm_rf @tmpdir end def test_autoindex err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] tmpdir = @tmpdir pid = mkserver(cfg) do $LOAD_PATH.unshift "#{Dir.pwd}/extras" require 'try_gzip_static' require 'autoindex' cfg.instance_eval do app(:rack, Autoindex.new(TryGzipStatic.new(tmpdir))) do listen "#{host}:#{port}" end stderr_path err.path end end Net::HTTP.start(host, port) do |http| res = http.request(Net::HTTP::Get.new("/")) assert_equal 200, res.code.to_i File.open("#@tmpdir/foo", "w").close res = http.request(Net::HTTP::Get.new("/")) assert_equal 200, res.code.to_i assert_match %r{foo}, res.body Dir.mkdir "#@tmpdir/bar" res = http.request(Net::HTTP::Get.new("/")) assert_equal 200, res.code.to_i assert_match %r{foo}, res.body assert_match %r{bar/}, res.body end ensure quit_wait pid end end
Version data entries
7 entries across 7 versions & 1 rubygems