     , (err, written) ->
       return next err if err
       written.should.eql 1
-      misc.file.readFile null, "#{scratch}/replace", (err, content) ->
+      misc.file.readFile ssh, "#{scratch}/replace", (err, content) ->
         return next err if err
         content.should.eql '#A config file\n#property=30\nproperty=50\n#End of Config'
         next()
   
-  it 'will replace destination if source or content does not exists', (next) ->
-    mecano.write
+  they 'will replace destination if source or content does not exists', (ssh, next) ->
+    mecano.write
+      ssh: ssh
       content: 'This is\nsome content\nfor testing'
       destination: "#{scratch}/a_file"
     , (err, written) ->
       return next err if err
       mecano.write
+        ssh: ssh
         match: /(.*content)/
         replace: 'a text'
         destination: "#{scratch}/a_file"

      err.message.should.eql 'Define either source or content'
      next()

  it 'append content to existing file', (next) ->
    # File does not exists, it create one
    mecano.write
      content: 'hello'
      destination: "#{scratch}/file"
      append: true

        return next err if err
        written.should.eql 1
        # Check file content
        misc.file.readFile ssh, "#{scratch}/file", (err, content) ->
          return next err if err
          content.should.eql 'Add this line'
          next()

  describe 'backup', ->
  
    they 'create a file', (ssh, next) ->
      # First we create a file
      mecano.write
        ssh: ssh
        content: 'Hello'
        destination: "#{scratch}/file"
      , (err, written) ->
        return next err if err
        # If nothing has change, there should be no backup
        mecano.write
          ssh: ssh
          content: 'Hello'
          destination: "#{scratch}/file"
          backup: '.bck'
        , (err, written) ->
          return next err if err
          written.should.eql 0
          misc.file.exists null, "#{scratch}/file.bck", (err, exists) ->
            exists.should.be.false
            # If content is different, check the backup
            mecano.write
              ssh: ssh
              content: 'Hello Node'
              destination: "#{scratch}/file"
              backup: '.bck'
            , (err, written) ->
              return next err if err
              misc.file.readFile ssh, "#{scratch}/file.bck", (err, content) ->
                content.should.eql 'Hello Node'
                next()


