         target: "#{scratch}/file"
         source: "#{scratch}/does/not/exists"
         local: true
-      , (err, written) ->
+      , (err) ->
         err.message.should.eql "Source does not exist: \"#{scratch}/does/not/exists\""
         next()
 
   describe 'eof', ->
 
     they 'auto-detected', (ssh, next) ->
-      mecano.file
-        ssh: ssh
+      mecano
+        ssh: ssh
+      .file
         target: "#{scratch}/file"
         content: 'this is\r\nsome content'
         eof: true
-      , (err) ->
-        return next err if err
-        fs.readFile ssh, "#{scratch}/file", (err, content) ->
-          content.toString().should.eql 'this is\r\nsome content\r\n'
-          next()
+      , (err, status) ->
+        status.should.be.true() unless err
+      .file.assert
+        target: "#{scratch}/file"
+        content: 'this is\r\nsome content\r\n'
+      .then next
 
     they 'not detected', (ssh, next) ->
-      mecano.file
+      mecano
+        ssh: ssh
+      .file
         ssh: ssh
         target: "#{scratch}/file"
         content: 'this is some content'
         eof: true
-      , (err) ->
-        return next err if err
-        fs.readFile ssh, "#{scratch}/file", (err, content) ->
-          content.toString().should.eql 'this is some content\n'
-          next()
+      , (err, status) ->
+        status.should.be.true() unless err
+      .file.assert
+        target: "#{scratch}/file"
+        content: 'this is some content\n'
+      .then next


      they 'place_before true, replace a string, match a regexp', (ssh, next) ->
        # Prepare by creating a file with content
        mecano.file
          ssh: ssh
          target: "#{scratch}/file"
          content: 'you coquin\nhere we are\n'
        , (err) ->
          # File does not exist, it create it with the content
          mecano.file
            ssh: ssh
            target: "#{scratch}/file"
            match: /.*coquin/
            replace: 'new coquin'
            place_before: true
          , (err, written) ->
            return next err if err
            written.should.be.true()
            fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
              return next err if err
              content.should.eql 'new coquin\nhere we are\n'
              # Write a second time with same match
              mecano.file
                ssh: ssh
                target: "#{scratch}/file"
                match: /.*coquin/
                replace: 'new coquin'
                place_before: true
              , (err, written) ->
                return next err if err
                written.should.be.false()
                # Check file content
                fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
                  return next err if err
                  content.should.eql 'new coquin\nhere we are\n'
                  next()

      they 'place_before true, replace a string, match a string', (ssh, next) ->
        # Prepare by creating a file with content
        mecano.file
          ssh: ssh
          target: "#{scratch}/file"
          content: 'you coquin\nhere we are\n'
        , (err) ->
          # File does not exist, it create it with the content
          mecano.file
            ssh: ssh
            target: "#{scratch}/file"
            match: "you coquin"
            replace: 'new coquin'
            place_before: true
          , (err, written) ->
            return next err if err
            written.should.be.true()
            fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
              return next err if err
              content.should.eql 'new coquin\nhere we are\n'
              # Write a second time with same match
              mecano.file
                ssh: ssh
                target: "#{scratch}/file"
                match: "new coquin"
                replace: 'new coquin'
                place_before: true
              , (err, written) ->
                return next err if err
                written.should.be.false()
                # Check file content
                fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
                  return next err if err
                  content.should.eql 'new coquin\nhere we are\n'
                  next()

      they 'place_after', (ssh, next) ->
        # Prepare by creating a file with content
        mecano.file
          ssh: ssh
          target: "#{scratch}/file"
          content: 'here we are\nyou coquin\n'
        , (err) ->
          # File does not exist, it create it with the content
          mecano.file
            ssh: ssh
            target: "#{scratch}/file"
            match: /.*coquin/
            replace: 'new coquin'
            append: true
          , (err, written) ->
            return next err if err
            written.should.be.true()
            fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
              return next err if err
              content.should.eql 'here we are\nnew coquin\n'
              # Write a second time with same match
              mecano.file
                ssh: ssh
                target: "#{scratch}/file"
                match: /.*coquin/
                replace: 'new coquin'
                append: true
              , (err, written) ->
                return next err if err
                written.should.be.false()
                # Check file content
                fs.readFile ssh, "#{scratch}/file", 'utf8', (err, content) ->
                  return next err if err
                  content.should.eql 'here we are\nnew coquin\n'
                  next()

    they 'will append if no match', (ssh, next) ->
      # Prepare by creating a file with content


  scratch = test.scratch @

  describe 'options content', ->
  
    they 'is a string', (ssh, next) ->
      mecano
        ssh: ssh
      .file
        target: "#{scratch}/file"
        content: 'Hello'
      , (err, status) ->
        status.should.be.true() unless err
      .file
        target: "#{scratch}/file"
        content: 'Hello'
      , (err, status) ->
        status.should.be.false() unless err
      .file.assert
        target: "#{scratch}/file"
        content: 'Hello'
      .then next
          
    they 'is a function', (ssh, next) ->
      content = 'invalid'
      mecano
