Skip to content

Instantly share code, notes, and snippets.

@hedefalk
Created March 31, 2016 08:37
Show Gist options
  • Save hedefalk/adccbaeb10c7285686d19e9263fda6c5 to your computer and use it in GitHub Desktop.
Save hedefalk/adccbaeb10c7285686d19e9263fda6c5 to your computer and use it in GitHub Desktop.
gaze = require 'gaze'
temp = (require 'temp').track()
path = require 'path'
fs = require 'fs'
describe 'gaze', ->
tempDir = undefined
beforeEach ->
tempDir = temp.mkdirSync('gaze-test')
afterEach ->
temp.cleanupSync()
testFile = (expectedFile) ->
spy = jasmine.createSpy('callback')
{dir, base} = path.parse expectedFile
gaze('**/*', {cwd: dir}, (err, watcher) ->
watcher.on('added', (event, path) -> spy()))
fs.writeFile(expectedFile, 'Hello Gaze, see me!',
(err) -> throw err if (err))
waitsFor( (-> spy.callCount > 0), "callback wasn't called in time", 5000)
it "should notice absolute paths if relativized", ->
testFile(path.join process.cwd(), 'foo')
it "should notice absolute paths if relativized, even from temp", ->
testFile(path.join tempDir, 'foo')
@hedefalk
Copy link
Author

The first test succeeds even though it takes like 100 secs because my cwd is pretty big. tempDir is empty so this is fast, but fails. No added event is triggered. I guess this might be a dup of shama/gaze#177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment