Skip to content

Instantly share code, notes, and snippets.

Last active December 30, 2015 00:09
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
require 'express'
class Server
constructor: ->
@app = express()
@server = http.createServer(@app)
@io = SocketIO.listen @server, logger: @logger
start: =>
@server.listen 3000
process.send? status: 'started' # if send is defined, we are inside the fork
configure_app: =>
# spec/requests/
TestServer = require '../helpers/test_server'
describe 'Login Page', ->
beforeAll (done) ->
@server = new TestServer done
afterAll (done) ->
@server.destroy done
# spec/helpers/
# This module is included in all the specs
fork = require('child_process').fork
class TestServer
childCmd: ""
cwd : "#{__dirname}/../.."
execPath: "./node_modules/coffee-script/bin/coffee"
constructor: (done) ->
@child = fork @childCmd, [], @childSettings
@child.on 'message', (data) ->
done() if data.status is 'message'
destroy: (done) =>
@child.on 'exit', -> done()
@child.kill 'SIGTERM'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment