Sha256: c2c1367cad9ade8a7b1e889aeddfb3d54235bdb774437a7b3d89be780bb3f9f7

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 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.should == "hello"
      end
    end
  end
end


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
goliath-1.0.3 spec/integration/websocket_spec.rb
goliath-1.0.2 spec/integration/websocket_spec.rb
goliath-1.0.1 spec/integration/websocket_spec.rb
goliath-1.0.0 spec/integration/websocket_spec.rb
goliath-1.0.0.beta.1 spec/integration/websocket_spec.rb