Removed spec crap
Before adoption: this commit came in with the history the project adopted, so no landing records it.
not a good fit for async
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent a42aaa2 · Browse files · 2 files·+0 added−180 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+0 added−180 removed
- tests:+0 added−178 removed
- other:+0 added−2 removed
Provenance
- Commit
a3aefb6- Tree
905588b- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
a42aaa2
2 files changed+0 added−180 removed
deleted:lib/express/spec/mocks.js-178 removed
1-2-// Express - MockRequest - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3-4-/**5- * Module dependencies.6- */7- 8-var Request = require('express/request').Request,9- path = require('path'),10- fs = require('fs')11-12-/**13- * Sync fs.readFile()14- */15- 16-fs.readFile = function(path, encoding, callback) {17- if (encoding instanceof Function)18- callback = encoding,19- encoding = null20- try {21- callback(null, fs.readFileSync(path, encoding))22- } catch (e) {23- callback(e)24- }25-}26-27-/**28- * Sync path.exists()29- */30- 31-path.exists = function(path, callback) {32- try {33- fs.statSync(path)34- callback(true)35- } catch (e) {36- callback(false)37- }38-}39-40-/**41- * Sync fs.stat()42- */43- 44-fs.stat = function(path, callback) {45- try {46- callback(null, fs.statSync(path))47- } catch (e) {48- callback(e)49- }50-}51-52-// --- MockRequest53-54-var MockRequest = new Class({55- 56- /**57- * Default HTTP version.58- */59- 60- httpVersion: '1.1',61- 62- /**63- * Initialize with _method_, _path_ and _options_.64- *65- * @param {string} method66- * @param {string} path67- * @param {hash} options68- * @api private69- */70- 71- constructor: function(method, path, options) {72- this.method = method73- this.url = path74- this.connection = { remoteAddress: '127.0.0.1' }75- this.headers = {76- 'host': 'localhost',77- 'user-agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19',78- 'accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',79- 'accept-language': 'en-us',80- 'connection': 'keep-alive'81- }82- Object.mergeDeep(this, options)83- }84-})85-86-// --- MockResponse87-88-var MockResponse = new Class({89- 90- /**91- * Store _code_ and _headers_.92- */93- 94- writeHead: function(code, headers) {95- this.status = code96- this.headers = headers97- },98- 99- /**100- * Store _body_.101- */102- 103- write: function(body) {104- this.body = body105- },106- 107- /**108- * Flag response as finished.109- */110- 111- end: function() {112- this.finished = true113- }114-})115-116-/**117- * Mock a request with the given _method_, _path_,118- * and _options_. Returns the response for assertions.119- *120- * All _options_ are passed to MockRequest which121- * performs a deep copy so you may alter headers etc.122- *123- * @param {string} method124- * @param {string} path125- * @param {hash} options126- * @return {MockResponse}127- * @api private128- */129-130-function request(method, path, options, callback) {131- var req = new MockRequest(method, path, options),132- res = new MockResponse133- Express.server.route(new Request(req, res))134- return res135-}136-137-/**138- * Request Express data which may have been139- * manipulated by the mock request.140- *141- * @api public142- */143-144-reset = function() {145- Express.routes = []146- Express.plugins = []147- Express.settings = {}148- Express.params = {}149- delete Express.notFound150- delete Express.error151- configure('test')152-}153-154-/**155- * Return a mock routing function for _method_.156- *157- * @param {string} method158- * @return {function}159- * @api private160- */161-162-function route(method) {163- return function(path, options, callback){164- if (options instanceof Function)165- callback = options, options = {}166- if (callback instanceof Function)167- Express.routes.push(new Route(method, path, callback, options))168- else169- return request(method, path, options, callback)170- }171-}172-173-// --- Mock routing API174-175-get = view = route('get')176-post = create = route('post')177-del = destroy = route('delete')178-put = update = route('put')deleted:lib/express/spec.js-2 removed
12
require('./spec/mocks')No newline at end of file