Sha256: 5d5723cc707b476f08b10cd08fada2db30b4ab2b206a4ae754b9b75761d21316

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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|
      expect_any_instance_of(WebSocketEndPoint).to 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"
        expect(client.receive.data).to eq("hello")
      end
    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
goliath-1.0.7 spec/integration/websocket_spec.rb
goliath-1.0.6 spec/integration/websocket_spec.rb