diff --git a/.gitignore b/.gitignore index 1a0f534..96ddf93 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ build/test_results/* node_modules/ # Compiled css and js (from and stylus and coffeescript) -public/stylesheets/*.css -public/javascripts/*.js +lib/public/stylesheets/*.css +lib/public/javascripts/*.js # Node.js monitor module nodemon-ignore @@ -24,3 +24,4 @@ nodemon-ignore #ignoring selenium.jar selenium-server.jar + diff --git a/build/lib/buildHelper.coffee b/build/lib/buildHelper.coffee new file mode 100644 index 0000000..f7742a1 --- /dev/null +++ b/build/lib/buildHelper.coffee @@ -0,0 +1,5 @@ +child_process = require 'child_process' + +exports.execute = (command) -> + child_process.spawn '/bin/sh', ['-c', command], customFds: [0, 0, 0] + diff --git a/spec/spec_helper.js b/spec/spec_helper.js new file mode 100644 index 0000000..dcf7bd9 --- /dev/null +++ b/spec/spec_helper.js @@ -0,0 +1,9 @@ +require('jessie').sugar() +require('coffee-script'); + +// More sugar +any = jasmine.any +stub = jasmine.createSpy +stubObj = jasmine.createSpyObj +noop = function() {/*NoOp*/} + diff --git a/spec/unit/server_spec.coffee b/spec/unit/server_spec.coffee new file mode 100644 index 0000000..27760b4 --- /dev/null +++ b/spec/unit/server_spec.coffee @@ -0,0 +1,30 @@ +WRITEBOARD_SERVER = '../../lib/server' + +describe 'The Writeboard server', -> + beforeEach -> + @webAppMock = stubObj 'webAppMock', ['configure', 'listen'] + @expressMock = createServer: noop + spyOn(@expressMock, 'createServer').andReturn @webAppMock + + it 'should create an Express web application', -> + require(WRITEBOARD_SERVER) @expressMock + @expressMock.createServer.should_have_been_called() + + it 'should be configured', -> + require(WRITEBOARD_SERVER) @expressMock + @webAppMock.configure.should_have_been_called_with any Function + + it 'should listen on port 9796', -> + require(WRITEBOARD_SERVER) @expressMock + @webAppMock.listen.should_have_been_called_with 9796 + + it 'should initialize the controllers', -> + controllerOne = stub 'controllerOne' + controllerTwo = stub 'controllerTwo' + nowJsStub = stub 'nowJs' + + require(WRITEBOARD_SERVER) @expressMock, (stub 'stylus'), (stub 'nib'), nowJsStub, + controllerOne, controllerTwo + controllerOne.should_have_been_called_with @webAppMock, nowJsStub + controllerTwo.should_have_been_called_with @webAppMock, nowJsStub +