Sha256: b150ca3f8cbcdfc65f043db7439bfa008e9bf03164cbd087ffc337f2b8cf246f

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require "test_helper"
require "rack/http_streaming_response"

class HttpStreamingResponseTest < Test::Unit::TestCase

  def setup
    host, req = "www.trix.pl", Net::HTTP::Get.new("/")
    @response = Rack::HttpStreamingResponse.new(req, host)
  end

  def test_streaming
    # Response status
    assert @response.code == 200
    assert @response.status == 200

    # Headers
    headers = @response.headers

    assert headers.size > 0

    assert headers["content-type"] == ["text/html;charset=utf-8"]
    assert headers["CoNtEnT-TyPe"] == headers["content-type"]
    assert headers["content-length"].first.to_i > 0

    # Body
    chunks = []
    @response.body.each do |chunk|
      chunks << chunk
    end

    assert chunks.size > 0
    chunks.each do |chunk|
      assert chunk.is_a?(String)
    end


  end

  def test_to_s
    assert_equal @response.headers["Content-Length"].first.to_i, @response.body.to_s.size
  end

  def test_to_s_called_twice
    body = @response.body
    assert_equal body.to_s, body.to_s
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rack-proxy-0.5.17 test/http_streaming_response_test.rb
rack-proxy-0.5.16 test/http_streaming_response_test.rb
rack-proxy-0.5.15 test/http_streaming_response_test.rb
rack-proxy-0.5.14 test/http_streaming_response_test.rb
rack-proxy-0.5.13 test/http_streaming_response_test.rb
rack-proxy-0.5.12 test/http_streaming_response_test.rb
rack-proxy-0.5.11 test/http_streaming_response_test.rb
rack-proxy-0.5.10 test/http_streaming_response_test.rb
rack-proxy-0.5.9 test/http_streaming_response_test.rb
rack-proxy-0.5.8 test/http_streaming_response_test.rb
rack-proxy-0.5.6 test/http_streaming_response_test.rb
rack-proxy-0.5.5 test/http_streaming_response_test.rb
rack-proxy-0.5.4 test/http_streaming_response_test.rb
rack-proxy-0.5.3 test/http_streaming_response_test.rb
rack-proxy-0.5.2 test/http_streaming_response_test.rb