             expect(@response.statusCode).to.equal 404
             expect(@body).to.exist
             expect(@body.error).to.equal 'Driver not found'
+
+    describe 'When we delete a Driver (DELETE /drivers/:id) with devices still depending on it', ->
+
+
+        before helpers.createDriver fixturesDriver.basicSensorDriver.file
+        before (done) ->
+            # We add the driver:
+            store.driverId = helpers.getInStore('driver').id
+            done null
+
+        before (done) ->
+            # We add the depending device:
+            sensor = fixturesSensor.supportedSensor1
+            sensor.driverId = store.driverId
+            helpers.createSensor(sensor) () ->
+                store.sensorId = helpers.getInStore('sensor').id
+                done null
+
+        it 'should allow requests', (done) ->
+            @client.del "drivers/#{store.driverId}", done
+
+        it 'should return an error', ->
+            expect(@response.statusCode).to.equal 500
+            expect(@body).to.exist
+            expect(@body.error).to.equal 'Devices still using this driver'
+
+        it 'when we try deleting the sensor first (DELETE /sensors/:id)', (done) ->
+            @client.del "sensors/#{store.sensorId}", done
+            
+        it '... then the driver (DELETE /drivers/:id)', (done) ->
+            @client.del "drivers/#{store.driverId}", done
+
+        it 'should return a "success"', ->
+            expect(@err).to.not.exist
+            expect(@response.statusCode).to.equal 200
+            expect(@body.success).to.equal true
 
     # @todo Find why required JS drivers are "undefined"
     # describe 'When we create a Sensor Driver (POST /drivers) as a JS script', ->

###

fixturesDriver = require '../fixtures/driver'
fs = require 'fs'
os = require 'os'
copyFile = require('../../server/helpers').copyFile

            expect(@body).to.exist
            expect(@body.error).to.equal 'Drivers can\'t be updated'

    describe 'When we delete a Driver (DELETE /drivers/:id) without devices', ->

        it 'should allow requests', (done) ->
            @client.del "drivers/#{store.driverId}", done
