Sha256: 41b8285296a2e206c46591ada2a202ea5daff8b2181e77a607de34cfd2c92779

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

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

class WebSocketEndPoint < Goliath::WebSocket
  def on_open(env)
  end

  def on_error(env, error)
    env.logger.error error
  end

  def on_message(env, msg)
    env.stream_send(msg)
  end

  def on_close(env)
  end
end

describe "WebSocket" do
  include Goliath::TestHelper

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

  it "should accept connection" do
    with_api(WebSocketEndPoint, {:verbose => true, :log_stdout => true}) do |server|
      WebSocketEndPoint.any_instance.should_receive(:on_open)
      ws_client_connect('/ws')
    end
  end

  it "should accept traffic" do
    with_api(WebSocketEndPoint, {:verbose => true, :log_stdout => true}) do |server|
      ws_client_connect('/ws') do |client|
        client.send "hello"
        client.receive.data.should == "hello"
      end
    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
goliath-1.0.5 spec/integration/websocket_spec.rb
goliath-1.0.4 spec/integration/websocket_spec.rb