 
 
     describe "indexing and searching", ->
-        it "Given I index four notes", (done) ->
+        it "Given I index four notes", (done) =>
             async.series [
                 createNoteFunction "Note 01", "little stories begin"
                 createNoteFunction "Note 02", "great dragons are coming"
                 createNoteFunction "Note 03", "small hobbits are afraid"
                 createNoteFunction "Note 04", "such as humans"
-            ], ->
+            ], =>
                 done()
             
         it "When I send a request to search the notes with dragons", (done) ->
+            data = ids: [dragonNoteId]
+            indexer = fakeServer data, 200, (url, body) ->
+                if url is '/index/'
+                    should.exist body.fields
+                    should.exist body.doc
+                    should.exist body.doc.docType
+
+            indexer.listen 9102
+
             client.post "data/search/note", { query: "dragons" }, \
                     (error, response, body) =>
                 @result = body
+                indexer.close()
                 done()
 
         it "Then result is the second note I created", ->


        client.post "data/", note, (error, response, body) ->
            console.log error if error
            client.post "data/index/#{body._id}",
                fields: ["title", "content"]
                , callback


describe "Indexation", ->

    # Start application before starting tests.
    before (done) ->
        app.listen(8888)
        done()

    # Clear DB, create a new one, then init data for tests.


# helpers

dragonNoteId = "0"

# Function for async to create and index notes
createNoteFunction = (title, content) ->
    (callback) ->
