Sha256: d38239b0c954708a3d8bac094be3fefcfff5ee282338e64b1df3b3081a3ecdd1

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

shared_examples_for 'all drafts' do
  it "should accept incoming connection" do
    conn = new_server_connection
    conn.write(handshake_request)
    conn.read(handshake_response.length).should eql(handshake_response)
  end
  it "should call 'on_open' on new connection" do
    TestApp.any_instance.expects(:on_open)
    conn = new_server_connection
    conn.write(handshake_request)
  end
  it "should call 'on_open' on new connection with proper env" do
    TestApp.any_instance.expects(:on_open).once.with { |env| env.class == Hash && !env.keys.empty? }
    conn = new_server_connection
    conn.write(handshake_request)
  end
  it "should call 'on_close' on connection close" do
    TestApp.any_instance.expects(:on_close)
    conn = new_server_connection
    conn.write(handshake_request)
    conn.close
  end
  it "should call 'on_close' on connection close with proper env" do
    TestApp.any_instance.expects(:on_close).once.with { |env| env.class == Hash && !env.keys.empty? }
    conn = new_server_connection
    conn.write(handshake_request)
    conn.close
  end
  it "should call 'on_message' on connection sending data" do
    TestApp.any_instance.expects(:on_message)
    conn = new_server_connection
    conn.write(handshake_request)
    conn.read(handshake_response.length)
    conn.write(message)
  end
  it "should call 'on_message' on connection sending data with proper env and message" do
    TestApp.any_instance.expects(:on_message).once.with { |env, message| env.class == Hash && !env.keys.empty? && message == 'some message' }
    conn = new_server_connection
    conn.write(handshake_request)
    conn.read(handshake_response.length)
    conn.write(message)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
websocket-rack-0.3.0 spec/support/all_drafts.rb
websocket-rack-0.2.1 spec/support/all_drafts.rb