 
 parseBody = (response, body) ->
     if typeof body is "object" then body else JSON.parse body
+
+randomString = (length=32) ->
+    string = ""
+    string += Math.random().toString(36).substr(2) while string.length < length
+    string.substr 0, length
 
 # Clear DB, create a new one, then init data for tests.
 before (done) ->


        it "Then the id of the new document should be returned", ->
            @body.should.have.property '_id'



    describe "Create a new Document with a given id", ->
        before cleanRequest
        after ->
            delete @randomValue

        it "When I send a request to create a document with id 987", (done) ->
            @randomValue = randomString()
            client.post 'data/987/', {"value":@randomValue}, \
                        (error, response, body) =>
                response.statusCode.should.equal 201
                @body = parseBody response, body
