 
         it "Then it sends me back my app with an id and a state", ->
             @response.statusCode.should.equal 201
-            should.exist @body.id
-            should.exist @body.state
+            should.exist @body.success
+            should.exist @body.app
+            should.exist @body.app.slug
+            should.exist @body.app.port
+            @body.success.should.ok
+            @body.app.slug.should.equal "my-app"
+            @body.app.port.should.equal 8001
 
         it "When I send a request to retrieve all applications", (done) ->
             client.get "api/applications", (error, response, body) =>

    createApp()


describe "Applications", ->

    before (done) ->
        server.listen(8888)

        it "Then I got expected application in a list", ->
            @body.rows.length.should.equal 2
            @body.rows[1].name.should.equal "My App"


describe "Application uninstallation", ->
    
    before ->
        @haibu = fakeServer msg: "ok" , 200, (body) ->
            should.exist body.user
            should.exist body.name
            should.exist body.repository
            should.exist body.scripts
        @haibu.listen 9002
        @proxy = fakeServer msg: "ok", 204, (body) ->
            should.exist body.route
            body.route.should.equal "/apps/my-app/"
        @proxy.listen 4000

    after ->
        @haibu.close()
        @proxy.close()

    describe "DELETE /api/applications/:slug/uninstall Remove an app", ->
        
        it "When I send a request to uninstall an application", (done) ->
            client.delete "api/applications/my-app/uninstall", \
                          (error, response, body) =>
                @response = response
                @body = JSON.parse body
                done()

        it "Then it sends me a success response", ->
            @response.statusCode.should.equal 200
            should.exist @body.success
            @body.success.should.be.ok
            
        it "When I send a request to retrieve all applications", (done) ->
            client.get "api/applications", (error, response, body) =>
                @body = JSON.parse body
                done()

        it "Then I got not see my application in the list", ->
            @body.rows.length.should.equal 1
            @body.rows[0].name.should.not.equal "My App"


describe "Users", ->
