 temp.track()
 
 describe 'PathWatcher', ->
-  tempFile = temp.openSync('node-pathwatcher-file')
   tempDir = temp.mkdirSync('node-pathwatcher-directory')
+  tempFile = path.join(tempDir, 'file')
 
   beforeEach ->
-    fs.writeFileSync(tempFile.path, '')
+    fs.writeFileSync(tempFile, '')
 
   afterEach ->
     pathWatcher.closeAllWatchers()

    it 'fires the callback with the event type and new path and watches the new path', ->
      eventType = null
      eventPath = null
      watcher = pathWatcher.watch tempFile.path, (type, path) ->
        eventType = type
        eventPath = path

      tempRenamed = temp.path('node-pathwatcher-renamed')
      fs.renameSync(tempFile.path, tempRenamed)
      waitsFor -> eventType?
      runs ->
        expect(eventType).toBe 'rename'

    it 'fires the callback with the event type and empty path', ->
      eventType = null
      eventPath = null
      watcher = pathWatcher.watch tempFile, (type, path) ->
        eventType = type
        eventPath = path

      fs.writeFileSync(tempFile, 'changed')
      waitsFor -> eventType?
      runs ->
        expect(eventType).toBe 'change'
