 
     it 'should encode the data and send it through the WebSocket object', ->
       message = ['event','message']
+      @connection._conn =
+        send: -> true
       mock_connection = sinon.mock @connection._conn
       mock_connection.expects('send').once().withArgs JSON.stringify(message)
       @connection.trigger 'event', 'message', 123

    dispatcher =
      new_message: -> true
      dispatch: -> true
    WebSocket = (url) ->
      @url  = url
      @send = ->
    @connection = new WebSocketRails.WebSocketConnection('localhost:3000/websocket',dispatcher)

  describe 'constructor', ->


    it 'should encode the data and send it through the WebSocket object', ->
      message = ['channel','event','message']
      @connection._conn =
        send: -> true
      mock_connection = sinon.mock @connection._conn
      mock_connection.expects('send').once().withArgs JSON.stringify(message)
      @connection.trigger_channel 'channel', 'event', 'message', 123
