spec/reel/websocket_spec.rb in reel-0.4.0.pre7 vs spec/reel/websocket_spec.rb in reel-0.4.0

- old
+ new

@@ -5,11 +5,12 @@ let(:example_message) { "Hello, World!" } let(:another_message) { "What's going on?" } it "performs websocket handshakes" do - with_socket_pair do |client, connection| + with_socket_pair do |client, peer| + connection = Reel::Connection.new(peer) client << handshake.to_data request = connection.request request.should be_websocket @@ -19,11 +20,12 @@ handshake.errors.should be_empty end end it "raises an error if trying to close a connection upgraded to socket" do - with_socket_pair do |client, connection| + with_socket_pair do |client, peer| + connection = Reel::Connection.new(peer) client << handshake.to_data websocket = connection.request.websocket websocket.should be_a Reel::WebSocket expect { connection.close }.to raise_error(Reel::Connection::StateError) @@ -74,11 +76,12 @@ websocket.should be_closed end end it "raises a RequestError when connection used after it was upgraded" do - with_socket_pair do |client, connection| + with_socket_pair do |client, peer| + connection = Reel::Connection.new(peer) client << handshake.to_data remote_host = connection.remote_host request = connection.request @@ -90,10 +93,11 @@ websocket.remote_host.should == remote_host end end def with_websocket_pair - with_socket_pair do |client, connection| + with_socket_pair do |client, peer| + connection = Reel::Connection.new(peer) client << handshake.to_data request = connection.request request.should be_websocket websocket = request.websocket