Created
July 26, 2012 01:43
-
-
Save jccarbonfive/3179778 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| fs = require 'fs' | |
| describe '#readFile', -> | |
| content = null | |
| done = false | |
| beforeEach -> | |
| runs -> | |
| fs.readFile __filename, (error, data) -> | |
| throw error if error? | |
| content = data | |
| done = true | |
| waitsFor -> | |
| done | |
| it 'reads the contents of the file', -> | |
| runs -> | |
| expect(content).not.toBeNull() |
This file contains hidden or 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
| fs = require 'fs' | |
| describe '#readFile', -> | |
| content = null | |
| beforeEach (done) -> | |
| fs.readFile __filename, (error, data) -> | |
| throw error if error? | |
| content = data | |
| done() | |
| it 'reads the contents of the file', -> | |
| expect(content).not.toBeNull() |
This file contains hidden or 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
| express = require 'express' | |
| request = require 'request' | |
| { expect } = require 'chai' | |
| app = express.createServer() | |
| app.get '/register', (_, response) -> | |
| response.send 200 | |
| server = app.listen 8500 | |
| describe '/register', -> | |
| beforeEach (done) -> | |
| request 'http://localhost:8500/register', | |
| (error, response) => | |
| return error if error? | |
| @response = response | |
| done() | |
| it 'is successful', -> | |
| expect(@response.statusCode).to.equal 200 |
This file contains hidden or 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
| express = require 'express' | |
| socketIo = require 'socket.io' | |
| ioClient = require 'socket.io-client' | |
| vows = require 'vows' | |
| assert = require 'assert' | |
| app = express.createServer() | |
| app.get '/', (_, response) -> | |
| response.send 200 | |
| server = app.listen 8500 | |
| io = socketIo.listen server | |
| io.sockets.on 'connection', (socket) -> | |
| socket.emit 'message', 'hi' | |
| vows | |
| .describe('Socket server') | |
| .addBatch | |
| 'when a client connects': | |
| topic: -> | |
| socket = ioClient.connect 'http://localhost:8500' | |
| socket.on 'message', @callback | |
| return undefined | |
| 'sends a welcome message to them': (message, _) -> | |
| assert.equal message, 'hi' | |
| .export(module) |
This file contains hidden or 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
| request = require 'request' | |
| events = require 'events' | |
| vows = require 'vows' | |
| assert = require 'assert' | |
| nock = require 'nock' | |
| class Google | |
| @search: (query, callback) -> | |
| options = | |
| uri: 'http://www.google.com/search' | |
| qs: | |
| q: query | |
| request options, callback | |
| vows | |
| .describe('Google') | |
| .addBatch | |
| '.search': | |
| topic: -> | |
| query = 'q' | |
| nock('http://www.google.com') | |
| .get("/search?q=#{query}") | |
| .reply 200 | |
| promise = new events.EventEmitter | |
| Google.search query, (_, response) => | |
| promise.emit 'success', response | |
| promise | |
| 'searches google for the given query': (_, response) -> | |
| assert.equal response.statusCode, 200 | |
| .export module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment