spec/faye/websocket/client_spec.rb in faye-websocket-0.4.0 vs spec/faye/websocket/client_spec.rb in faye-websocket-0.4.1

- old
+ new

@@ -58,17 +58,17 @@ def listen_for_message(&callback) @ws.add_event_listener('message', lambda { |e| @message = e.data }) callback.call end - def send_message(&callback) - @ws.send("I expect this to be echoed") + def send_message(message, &callback) + @ws.send(message) EM.add_timer(0.1, &callback) end - def check_response(&callback) - @message.should == "I expect this to be echoed" + def check_response(message, &callback) + @message.should == message callback.call end def check_no_response(&callback) @message.should == nil @@ -114,23 +114,29 @@ describe "in the OPEN state" do before { open_socket(socket_url, protocols) } it "can send and receive messages" do listen_for_message - send_message - check_response + send_message "I expect this to be echoed" + check_response "I expect this to be echoed" end + + it "sends numbers as strings" do + listen_for_message + send_message 13 + check_response "13" + end end describe "in the CLOSED state" do before do open_socket(socket_url, protocols) close_socket end it "cannot send and receive messages" do listen_for_message - send_message + send_message "I expect this to be echoed" check_no_response end end end