           'with response callback': ({ requestObject }) ->
             assert.isTrue requestObject.on.calledWith 'response'
 
-          'and respond to response event':
+          'with response handler to':
             topic: ({ callback, requestObject }) ->
               responseObject =
                 on: sinon.stub()

              callback: callback
              responseObject: responseObject

            'to set encoding to utf8': ({ responseObject }) ->
              responseObject.setEncoding.alwaysCalledWith 'utf8'

            'to respond':

              'to data events': ({ responseObject }) ->
                responseObject.on.calledWith 'data'

              'to end event': ({ responseObject }) ->
                responseObject.on.calledWith 'end'

              'to error event': ({ responder, responseObject }) ->
                responseObject.on.calledWith 'error', responder

)()



      'with no options':
        topic: -> factory()

        'should call connector.request':
          calledOnce withEmptyOptions returningRequestObject()

      'with data':
        topic: ->
          data =
            message: 'Hello World!'
            fn: -> 'Goodbye World!'

          context = factory data: data
          context.data = data
          context

        'should call connector.request':
          calledOnce returningRequestObject

            'with headers': ({ request }) ->
              assert.ok headers = request.getCall(0).args[0].headers
              assert.strictEqual headers['Content-Type'], 'application/json'
              assert.isTrue headers['Content-Length'] > 0

            'with json parsable data': ({ request, data }) ->
              js = null
              assert.ok json = request.getCall(0).args[0].data
              assert.doesNotThrow (-> js = JSON.parse(json) ), SyntaxError
              assert.strictEqual js.message, data.message
              assert.match js.fn, ///
                \b
                  function (\s|\\n)* \(\) (\s|\\n)* \{ (\s|\\n)*
                    \b return \b (\s|\\n)* 'Goodbye\sWorld!' (\s|\\n)* ; (\s|\\n)*
                  \}
              ///

      'with data emitter':
        topic: -> factory data: on: sinon.stub()
