postrank-labs / goliath

Goliath is a non-blocking Ruby web server framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StreamingHelper doesn't seem to actually work

kornypoet opened this issue · comments

Altering the included integration test does not cause the test to fail as expected:

# from spec/integration/chunked_streaming_spec.rb

require 'spec_helper'
require File.join(File.dirname(__FILE__), '../../', 'lib/goliath/test_helper_streaming')
require File.join(File.dirname(__FILE__), '../../', 'lib/goliath')

class ChunkedStreaming < Goliath::API

  def response(env)

    EM.next_tick do
      env.chunked_stream_send("ignored") # originally "chunked"
      env.chunked_stream_close
    end

    headers = { 'Content-Type' => 'text/plain', 'X-Stream' => 'Goliath' }
    chunked_streaming_response(200, headers)
  end

  def on_close(env)
  end
end

describe "ChunkedStreaming" do
  include Goliath::TestHelper

  let(:err) { Proc.new { |c| fail "HTTP Request failed #{c.response}" } }

  it "should stream content" do
    with_api(ChunkedStreaming, {:verbose => true, :log_stdout => true}) do |server|
      streaming_client_connect('/streaming') do |client|
        # this should raise an RSpec::ExpectationNotMet,
        # however this block is never actually called
        client.receive.should == "chunked"
      end
    end
  end
end

Running the above test (using bundle exec rspec spec/integration/chunked_streaming_spec.rb) incorrectly still passes, which leads me to believe the StreamingHelper itself is broken. This was checked against master.