pulsar/spec/task-spec.coffee

23 lines
703 B
CoffeeScript
Raw Normal View History

2013-09-18 05:58:41 +04:00
Task = require '../src/task'
2013-06-13 01:09:22 +04:00
describe "Task", ->
2013-06-15 03:09:38 +04:00
describe "@once(taskPath, args..., callback)", ->
it "terminates the process after it completes", ->
handlerResult = null
2013-09-18 03:15:53 +04:00
task = Task.once require.resolve('./fixtures/task-spec-handler'), (result) ->
2013-06-15 03:09:38 +04:00
handlerResult = result
processClosed = false
processErrored = false
childProcess = task.childProcess
spyOn(childProcess, 'kill').andCallThrough()
task.childProcess.on 'error', -> processErrored = true
waitsFor ->
handlerResult?
runs ->
expect(handlerResult).toBe 'hello'
expect(childProcess.kill).toHaveBeenCalled()
expect(processErrored).toBe false