1 # -*- encoding: binary -*-
7 class TestRackFileCompat < Test::Unit::TestCase
9 @app = Rack::File.new(File.dirname(__FILE__))
10 @req = Rack::MockRequest.new(@app)
11 @base_file = File.basename(__FILE__)
12 @r, @w = UNIXSocket.pair
16 [ @r, @w ].each { |io| io.closed? or io.close }
19 def test_get_rack_file
20 env = Rack::MockRequest.env_for "http://example.com/#@base_file"
21 status, headers, body = @app.call(env)
22 assert_equal 200, status.to_i
24 assert_instance_of String, k.to_str
25 assert_instance_of String, v.to_str
27 thr = Thread.new { @r.read(File.size(__FILE__)) }
28 assert_equal File.size(__FILE__), IO::Splice.copy_stream(body, @w)
29 assert_equal File.read(__FILE__), thr.value
31 end if IO.respond_to?(:copy_stream)