forked from xonev/coffee-shop
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c683046
Showing
9 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/** | ||
.DS_STORE | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coffee: coffee -wc -o public/javascripts/ client/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "chat-server", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"coffee-script": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def jessie | ||
system('jessie spec -f nested') | ||
puts "=====================" | ||
end | ||
|
||
watch('spec/.*\.coffee') { jessie() } | ||
watch('server/.*\.coffee') { jessie() } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{EventEmitter} = require('events') | ||
|
||
Messager = new EventEmitter | ||
|
||
messages = [] | ||
|
||
Messager.add = (message) -> | ||
messages.push(message) | ||
@emit('add', message) | ||
|
||
Messager.messages = -> | ||
messages | ||
|
||
exports.Messager = Messager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class User | ||
constructor: (@name, @password) -> | ||
validate: -> | ||
true | ||
@toString: -> | ||
'User' | ||
|
||
exports.User = User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{Messager} = require_root ('server/messager.coffee') | ||
|
||
describe 'Messager', -> | ||
it 'adds and retrieves messages', -> | ||
message = 'hey there!' | ||
Messager.add(message) | ||
messages = Messager.messages() | ||
expect(messages[0]).toBe(message) | ||
|
||
it 'notifies listeners of new messages', -> | ||
message = 'hello sir!' | ||
notification = null | ||
Messager.on 'add', (eventMessage) -> | ||
notification = eventMessage | ||
Messager.add(message) | ||
waitsFor -> | ||
notification? | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require('coffee-script') | ||
|
||
global.require_root = function(path) { | ||
var rootPath = process.env.PWD + '/' + path | ||
return require (rootPath) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{User} = require_root('server/user.coffee') | ||
|
||
describe User, -> | ||
it 'validates a username and password', -> | ||
user = new User | ||
user.name = 'pickles' | ||
user.password = '123password' | ||
success = user.validate() | ||
expect(success).toBe(true) | ||
|