Sha256: d3f35d74099cc9ff0f5e2b414ea25a496b153a38048f4067f8bef3d0a1a0ec4e

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

shared_examples_for "a websocket server" do
  it "should call onerror if an application error raised in onopen" do
    EM.run {
      start_server { |ws|
        ws.onopen {
          raise "application error"
        }

        ws.onerror { |e|
          e.message.should == "application error"
          EM.stop
        }
      }

      start_client
    }
  end

  it "should call onerror if an application error raised in onmessage" do
    EM.run {
      start_server { |server|
        server.onmessage {
          raise "application error"
        }

        server.onerror { |e|
          e.message.should == "application error"
          EM.stop
        }
      }

      start_client { |client|
        client.onopen {
          client.send('a message')
        }
      }
    }
  end

  it "should call onerror in an application error raised in onclose" do
    EM.run {
      start_server { |server|
        server.onclose {
          raise "application error"
        }

        server.onerror { |e|
          e.message.should == "application error"
          EM.stop
        }
      }

      start_client { |client|
        client.onopen {
          EM.add_timer(0.1) {
            client.close_connection
          }
        }
      }
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-websocket-0.3.1 spec/integration/shared_examples.rb
em-websocket-0.3.0 spec/integration/shared_examples.rb