Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

restructure

remove lib/mongoose dir
stop relying on expressos require.paths manipulation
remove support/should.js
  • Loading branch information...
commit d89b2429850f9760159fd39010636b112165169d 1 parent add9878
@aheckmann aheckmann authored
Showing with 22 additions and 1,362 deletions.
  1. +1 −1  index.js
  2. 0  lib/{mongoose → }/collection.js
  3. 0  lib/{mongoose → }/connection.js
  4. 0  lib/{mongoose → }/document.js
  5. 0  lib/{mongoose → }/drivers/node-mongodb-native/binary.js
  6. 0  lib/{mongoose → }/drivers/node-mongodb-native/collection.js
  7. 0  lib/{mongoose → }/drivers/node-mongodb-native/connection.js
  8. 0  lib/{mongoose → }/drivers/node-mongodb-native/objectid.js
  9. 0  lib/{mongoose → }/error.js
  10. 0  lib/{mongoose → }/index.js
  11. 0  lib/{mongoose → }/model.js
  12. 0  lib/{mongoose → }/namedscope.js
  13. 0  lib/{mongoose → }/promise.js
  14. 0  lib/{mongoose → }/query.js
  15. 0  lib/{mongoose → }/schema.js
  16. 0  lib/{mongoose → }/schema/array.js
  17. 0  lib/{mongoose → }/schema/boolean.js
  18. 0  lib/{mongoose → }/schema/buffer.js
  19. 0  lib/{mongoose → }/schema/date.js
  20. 0  lib/{mongoose → }/schema/documentarray.js
  21. 0  lib/{mongoose → }/schema/index.js
  22. 0  lib/{mongoose → }/schema/mixed.js
  23. 0  lib/{mongoose → }/schema/number.js
  24. 0  lib/{mongoose → }/schema/objectid.js
  25. 0  lib/{mongoose → }/schema/string.js
  26. 0  lib/{mongoose → }/schemadefault.js
  27. 0  lib/{mongoose → }/schematype.js
  28. 0  lib/{mongoose → }/statemachine.js
  29. 0  lib/{mongoose → }/types/array.js
  30. 0  lib/{mongoose → }/types/buffer.js
  31. 0  lib/{mongoose → }/types/document.js
  32. 0  lib/{mongoose → }/types/documentarray.js
  33. 0  lib/{mongoose → }/types/index.js
  34. 0  lib/{mongoose → }/types/number.js
  35. 0  lib/{mongoose → }/types/objectid.js
  36. 0  lib/{mongoose → }/utils.js
  37. 0  lib/{mongoose → }/virtualtype.js
  38. +0 −3  support/should.js/.gitmodules
  39. +0 −22 support/should.js/History.md
  40. +0 −6 support/should.js/Makefile
  41. +0 −248 support/should.js/Readme.md
  42. +0 −53 support/should.js/examples/runner.js
  43. +0 −2  support/should.js/index.js
  44. +0 −91 support/should.js/lib/eql.js
  45. +0 −548 support/should.js/lib/should.js
  46. +0 −8 support/should.js/package.json
  47. +0 −358 support/should.js/test/should.test.js
  48. +1 −1  test/collection.test.js
  49. +2 −2 test/document.test.js
  50. +2 −2 test/model.querying.test.js
  51. +1 −1  test/model.ref.test.js
  52. +2 −2 test/model.test.js
  53. +1 −1  test/namedscope.test.js
  54. +1 −1  test/promise.test.js
  55. +1 −1  test/query.test.js
  56. +1 −1  test/schema.onthefly.test.js
  57. +1 −1  test/types.array.test.js
  58. +1 −1  test/types.buffer.test.js
  59. +2 −2 test/types.document.test.js
  60. +2 −3 test/types.documentarray.test.js
  61. +3 −3 test/utils.test.js
View
2  index.js
@@ -4,4 +4,4 @@
*
*/
-module.exports = require('./lib/mongoose/');
+module.exports = require('./lib/');
View
0  lib/mongoose/collection.js → lib/collection.js
File renamed without changes
View
0  lib/mongoose/connection.js → lib/connection.js
File renamed without changes
View
0  lib/mongoose/document.js → lib/document.js
File renamed without changes
View
0  ...ose/drivers/node-mongodb-native/binary.js → lib/drivers/node-mongodb-native/binary.js
File renamed without changes
View
0  ...drivers/node-mongodb-native/collection.js → ...drivers/node-mongodb-native/collection.js
File renamed without changes
View
0  ...drivers/node-mongodb-native/connection.js → ...drivers/node-mongodb-native/connection.js
File renamed without changes
View
0  ...e/drivers/node-mongodb-native/objectid.js → lib/drivers/node-mongodb-native/objectid.js
File renamed without changes
View
0  lib/mongoose/error.js → lib/error.js
File renamed without changes
View
0  lib/mongoose/index.js → lib/index.js
File renamed without changes
View
0  lib/mongoose/model.js → lib/model.js
File renamed without changes
View
0  lib/mongoose/namedscope.js → lib/namedscope.js
File renamed without changes
View
0  lib/mongoose/promise.js → lib/promise.js
File renamed without changes
View
0  lib/mongoose/query.js → lib/query.js
File renamed without changes
View
0  lib/mongoose/schema.js → lib/schema.js
File renamed without changes
View
0  lib/mongoose/schema/array.js → lib/schema/array.js
File renamed without changes
View
0  lib/mongoose/schema/boolean.js → lib/schema/boolean.js
File renamed without changes
View
0  lib/mongoose/schema/buffer.js → lib/schema/buffer.js
File renamed without changes
View
0  lib/mongoose/schema/date.js → lib/schema/date.js
File renamed without changes
View
0  lib/mongoose/schema/documentarray.js → lib/schema/documentarray.js
File renamed without changes
View
0  lib/mongoose/schema/index.js → lib/schema/index.js
File renamed without changes
View
0  lib/mongoose/schema/mixed.js → lib/schema/mixed.js
File renamed without changes
View
0  lib/mongoose/schema/number.js → lib/schema/number.js
File renamed without changes
View
0  lib/mongoose/schema/objectid.js → lib/schema/objectid.js
File renamed without changes
View
0  lib/mongoose/schema/string.js → lib/schema/string.js
File renamed without changes
View
0  lib/mongoose/schemadefault.js → lib/schemadefault.js
File renamed without changes
View
0  lib/mongoose/schematype.js → lib/schematype.js
File renamed without changes
View
0  lib/mongoose/statemachine.js → lib/statemachine.js
File renamed without changes
View
0  lib/mongoose/types/array.js → lib/types/array.js
File renamed without changes
View
0  lib/mongoose/types/buffer.js → lib/types/buffer.js
File renamed without changes
View
0  lib/mongoose/types/document.js → lib/types/document.js
File renamed without changes
View
0  lib/mongoose/types/documentarray.js → lib/types/documentarray.js
File renamed without changes
View
0  lib/mongoose/types/index.js → lib/types/index.js
File renamed without changes
View
0  lib/mongoose/types/number.js → lib/types/number.js
File renamed without changes
View
0  lib/mongoose/types/objectid.js → lib/types/objectid.js
File renamed without changes
View
0  lib/mongoose/utils.js → lib/utils.js
File renamed without changes
View
0  lib/mongoose/virtualtype.js → lib/virtualtype.js
File renamed without changes
View
3  support/should.js/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "support/expresso"]
- path = support/expresso
- url = git://github.com/visionmedia/expresso.git
View
22 support/should.js/History.md
@@ -1,22 +0,0 @@
-
-0.0.4 / 2010-11-24
-==================
-
- * Added `.ok` to assert truthfulness
- * Added `.arguments`
- * Fixed double required bug. [thanks dominictarr]
-
-0.0.3 / 2010-11-19
-==================
-
- * Added `true` / `false` assertions
-
-0.0.2 / 2010-11-19
-==================
-
- * Added chaining support
-
-0.0.1 / 2010-11-19
-==================
-
- * Initial release
View
6 support/should.js/Makefile
@@ -1,6 +0,0 @@
-
-test:
- @./support/expresso/bin/expresso \
- -I lib
-
-.PHONY: test
View
248 support/should.js/Readme.md
@@ -1,248 +0,0 @@
- _should_ is an expressive, test framework agnostic, assertion library for [node](http://nodejs.org).
-
-_should_ literally extends node's _assert_ module, in fact, it is node's assert module, for example `should.equal(str, 'foo')` will work, just as `assert.equal(str, 'foo')` would, and `should.AssertionError` **is** `asset.AssertionError`, meaning any test framework supporting this constructor will function properly with _should_.
-
-## Example
-
- var user = {
- name: 'tj'
- , pets: ['tobi', 'loki', 'jane', 'bandit']
- };
-
- user.should.have.property('name', 'tj');
- user.should.have.property('pets').with.lengthOf(4)
-
-## Installation
-
- $ npm install should
-
-## modifiers
-
- _should_'s assertion chaining provides an expressive way to build up an assertion, along with dummy getters such as _an_, _have_, and _be_, provided are what I am simply calling **modifiers**, which have a meaning effect on the assertion. An example of this is the _not_ getter, which negates the meaning, aka `user.should.not.have.property('name')`. In the previous example note the use of _have_, as we could omit it and still construct a valid assertion.
-
-Some modifiers such as _include_ only have an effect with specific assertion methods, for example when asserting a substring like so: `str.should.include.string('test')`, we could omit _include_, but it helps express the meaning, however _keys_ has a strict effect, unless the _include_ modifier is used.
-
-## chaining assertions
-
-Some assertions can be chained, for example if a property is volatile we can first assert property existence:
-
- user.should.have.property('pets').with.lengthOf(4)
-
-which is essentially equivalent to below, however the property may not exist:
-
- user.pets.should.have.lengthOf(4)
-
-our dummy getters such as _and_ also help express chaining:
-
- user.should.be.a('object').and.have.property('name', 'tj')
-
-## ok
-
-Assert truthfulness:
-
- true.should.be.ok
- 'yay'.should.be.ok
- (1).should.be.ok
-
-or negated:
-
- false.should.not.be.ok
- ''.should.not.be.ok
- (0).should.not.be.ok
-
-## true
-
-Assert === true:
-
- true.should.be.true
- '1'.should.not.be.true
-
-## false
-
-Assert === false:
-
- false.should.be.false
- (0).should.not.be.false
-
-## arguments
-
-Assert `Arguments`:
-
- var args = (function(){ return arguments; })(1,2,3);
- args.should.be.arguments;
- [].should.not.be.arguments;
-
-## empty
-
-Asserts that length is 0:
-
- [].should.be.empty
- ''.should.be.empty
- ({ length: 0 }).should.be.empty
-
-## eql
-
-equality:
-
- ({ foo: 'bar' }).should.eql({ foo: 'bar' })
- [1,2,3].should.eql([1,2,3])
-
-## equal
-
-strict equality:
-
- should.strictEqual(undefined, value)
- should.strictEqual(false, value)
- (4).should.equal(4)
- 'test'.should.equal('test')
- [1,2,3].should.not.equal([1,2,3])
-
-## within
-
-Assert inclusive numeric range:
-
- user.age.should.be.within(5, 50)
-
-## a
-
-Assert __typeof__:
-
- user.should.be.a('object')
- 'test'.should.be.a('string')
-
-## instanceof
-
-Assert __instanceof__:
-
- user.should.be.an.instanceof(User)
- [].should.be.an.instanceof(Array)
-
-## above
-
-Assert numeric value above the given value:
-
- user.age.should.be.above(5)
- user.age.should.not.be.above(100)
-
-## below
-
-Assert numeric value below the given value:
-
- user.age.should.be.below(100)
- user.age.should.not.be.below(5)
-
-## match
-
-Assert regexp match:
-
- username.should.match(/^\w+$/)
-
-## length
-
-Assert _length_ property exists and has a value of the given number:
-
- user.pets.should.have.length(5)
- user.pets.should.have.a.lengthOf(5)
-
-Aliases: _lengthOf_
-
-## string
-
-Substring assertion:
-
- 'foobar'.should.include.string('foo')
- 'foobar'.should.include.string('bar')
- 'foobar'.should.not.include.string('baz')
-
-## property
-
-Assert property exists and has optional value:
-
- user.should.have.property('name')
- user.should.have.property('age', 15)
- user.should.not.have.property('rawr')
- user.should.not.have.property('age', 0)
-
-## ownProperty
-
-Assert own property (on the immediate object):
-
- ({ foo: 'bar' }).should.have.ownProperty('foo')
-
-## contain
-
-Assert array value:
-
- [1,2,3].should.contain(3)
- [1,2,3].should.contain(2)
- [1,2,3].should.not.contain(4)
-
-## keys
-
-Assert own object keys, which must match _exactly_,
-and will fail if you omit a key or two:
-
- var obj = { foo: 'bar', baz: 'raz' };
- obj.should.have.keys('foo', 'bar');
- obj.should.have.keys(['foo', 'bar']);
-
-using the _include_ modifier, we can check inclusion of a key,
-but not fail when we omit a few:
-
- obj.should.include.keys('foo')
- obj.should.include.keys('bar')
- obj.should.not.include.keys('baz')
-
-## respondTo
-
-Assert that the given property is a function:
-
- user.should.respondTo('email')
-
-## Express example
-
-For example you can use should with the [Expresso TDD Framework](http://github.com/visionmedia/expresso) by simply including it:
-
- var lib = require('mylib')
- , should = require('should');
-
- module.exports = {
- 'test .version': function(){
- lib.version.should.match(/^\d+\.\d+\.\d+$/);
- }
- };
-
-## Running tests
-
-To run the tests for _should_ simple update your git submodules and run:
-
- $ make test
-
-## OMG IT EXTENDS OBJECT???!?!@
-
-Yes, yes it does, with a single getter _should_, and no it wont break your code, because it does this **properly** with a non-enumerable property.
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
53 support/should.js/examples/runner.js
@@ -1,53 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var should = require('../');
-
-function test(name, fn){
- try {
- fn();
- } catch (err) {
- console.log(' \x1b[31m%s', name);
- console.log(' %s\x1b[0m', err.stack);
- return;
- }
- console.log('\x1b[32m%s\x1b[0m', name);
-}
-
-function Point(x, y) {
- this.x = x;
- this.y = y;
- this.sub = function(other){
- return new Point(
- this.x - other.x
- , this.y - other.y);
- }
-}
-
-console.log();
-
-test('new Point(x, y)', function(){
- var point = new Point(50, 100);
- point.should.be.an.instanceof(Point);
- point.should.have.property('x', 50);
- point.should.have.property('y', 100);
-});
-
-test('Point#sub()', function(){
- var a = new Point(50, 100)
- , b = new Point(20, 50);
- a.sub(b).should.be.an.instanceof(Point);
- a.sub(b).should.not.equal(a);
- a.sub(b).should.not.equal(b);
- a.sub(b).should.have.property('x', 30);
- a.sub(b).should.have.property('y', 50);
-});
-
-test('Point#add()', function(){
- var point = new Point(50, 100);
- point.should.respondTo('add');
-});
-
-console.log();
View
2  support/should.js/index.js
@@ -1,2 +0,0 @@
-
-module.exports = require('./lib/should');
View
91 support/should.js/lib/eql.js
@@ -1,91 +0,0 @@
-
-// Taken from node's assert module, because it sucks
-// and exposes next to nothing useful.
-
-module.exports = _deepEqual;
-
-function _deepEqual(actual, expected) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
-
- } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
- if (actual.length != expected.length) return false;
-
- for (var i = 0; i < actual.length; i++) {
- if (actual[i] !== expected[i]) return false;
- }
-
- return true;
-
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (actual instanceof Date && expected instanceof Date) {
- return actual.getTime() === expected.getTime();
-
- // 7.3. Other pairs that do not both pass typeof value == "object",
- // equivalence is determined by ==.
- } else if (typeof actual != 'object' && typeof expected != 'object') {
- return actual == expected;
-
- // 7.4. For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical "prototype" property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else {
- return objEquiv(actual, expected);
- }
-}
-
-function isUndefinedOrNull (value) {
- return value === null || value === undefined;
-}
-
-function isArguments (object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
-}
-
-function objEquiv (a, b) {
- if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
- return false;
- // an identical "prototype" property.
- if (a.prototype !== b.prototype) return false;
- //~~~I've managed to break Object.keys through screwy arguments passing.
- // Converting to array solves the problem.
- if (isArguments(a)) {
- if (!isArguments(b)) {
- return false;
- }
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b);
- }
- try{
- var ka = Object.keys(a),
- kb = Object.keys(b),
- key, i;
- } catch (e) {//happens when one is a string literal and the other isn't
- return false;
- }
- // having the same number of owned properties (keys incorporates hasOwnProperty)
- if (ka.length != kb.length)
- return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] != kb[i])
- return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key] ))
- return false;
- }
- return true;
-}
View
548 support/should.js/lib/should.js
@@ -1,548 +0,0 @@
-
-/*!
- * Should
- * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var util = require('sys')
- , assert = require('assert')
- , AssertionError = assert.AssertionError
- , eql = require('./eql')
- , i = util.inspect;
-
-/**
- * Expose assert as should.
- *
- * This allows you to do things like below
- * without require()ing the assert module.
- *
- * should.equal(foo.bar, undefined);
- *
- */
-
-exports = module.exports = assert;
-
-/**
- * Library version.
- */
-
-exports.version = '0.0.4';
-
-/**
- * Expose api via `Object#should`.
- *
- * @api public
- */
-
-Object.defineProperty(Object.prototype, 'should', {
- set: function(){},
- get: function(){
- return new Assertion(this);
- }
-});
-
-/**
- * Initialize a new `Assertion` with the given _obj_.
- *
- * @param {Mixed} obj
- * @api private
- */
-
-var Assertion = exports.Assertion = function Assertion(obj) {
- this.obj = obj;
-};
-
-/**
- * Prototype.
- */
-
-Assertion.prototype = {
-
- /**
- * HACK: prevents double require() from failing.
- */
-
- exports: exports,
-
- /**
- * Assert _expr_ with the given _msg_ and _negatedMsg_.
- *
- * @param {Boolean} expr
- * @param {String} msg
- * @param {String} negatedMsg
- * @api private
- */
-
- assert: function(expr, msg, negatedMsg){
- var msg = this.negate ? negatedMsg : msg
- , ok = this.negate ? !expr : expr;
- if (!ok) {
- throw new AssertionError({
- message: msg
- , stackStartFunction: this.assert
- });
- }
- },
-
- /**
- * Dummy getter.
- *
- * @api public
- */
-
- get an() {
- return this;
- },
-
- /**
- * Dummy getter.
- *
- * @api public
- */
-
- get and() {
- return this;
- },
-
- /**
- * Dummy getter.
- *
- * @api public
- */
-
- get be() {
- return this;
- },
-
- /**
- * Dummy getter.
- *
- * @api public
- */
-
- get have() {
- return this;
- },
-
- /**
- * Dummy getter.
- *
- * @api public
- */
-
- get with() {
- return this;
- },
-
- /**
- * Inclusion modifier.
- *
- * @api public
- */
-
- get include() {
- this.includes = true;
- return this;
- },
-
- /**
- * Negation modifier.
- *
- * @api public
- */
-
- get not() {
- this.negate = true;
- return this;
- },
-
- /**
- * Get object inspection string.
- *
- * @return {String}
- * @api private
- */
-
- get inspect() {
- return i(this.obj);
- },
-
- /**
- * Assert instanceof `Arguments`.
- *
- * @api public
- */
-
- get arguments() {
- this.assert(
- '[object Arguments]' == Object.prototype.toString.call(this.obj)
- , 'expected ' + this.inspect + ' to be arguments'
- , 'expected ' + this.inspect + ' to not be arguments');
- return this;
- },
-
- /**
- * Assert that an object is empty aka length of 0.
- *
- * @api public
- */
-
- get empty() {
- this.obj.should.have.property('length');
- this.assert(
- 0 === this.obj.length
- , 'expected ' + this.inspect + ' to be empty'
- , 'expected ' + this.inspect + ' not to be empty');
- return this;
- },
-
- /**
- * Assert ok.
- *
- * @api public
- */
-
- get ok() {
- this.assert(
- this.obj
- , 'expected ' + this.inspect + ' to be truthy'
- , 'expected ' + this.inspect + ' to be falsey');
- return this;
- },
-
- /**
- * Assert true.
- *
- * @api public
- */
-
- get true() {
- this.assert(
- true === this.obj
- , 'expected ' + this.inspect + ' to be true'
- , 'expected ' + this.inspect + ' not to be true');
- return this;
- },
-
- /**
- * Assert false.
- *
- * @api public
- */
-
- get false() {
- this.assert(
- false === this.obj
- , 'expected ' + this.inspect + ' to be false'
- , 'expected ' + this.inspect + ' not to be false');
- return this;
- },
-
- /**
- * Assert equal.
- *
- * @param {Mixed} val
- * @api public
- */
-
- eql: function(val){
- this.assert(
- eql(val, this.obj)
- , 'expected ' + this.inspect + ' to equal ' + i(val)
- , 'expected ' + this.inspect + ' to not equal ' + i(val));
- return this;
- },
-
- /**
- * Assert strict equal.
- *
- * @param {Mixed} val
- * @api public
- */
-
- equal: function(val){
- this.assert(
- val === this.obj
- , 'expected ' + this.inspect + ' to equal ' + i(val)
- , 'expected ' + this.inspect + ' to not equal ' + i(val));
- return this;
- },
-
- /**
- * Assert within start to finish (inclusive).
- *
- * @param {Number} start
- * @param {Number} finish
- * @api public
- */
-
- within: function(start, finish){
- var range = start + '..' + finish;
- this.assert(
- this.obj >= start && this.obj <= finish
- , 'expected ' + this.inspect + ' to be within ' + range
- , 'expected ' + this.inspect + ' to not be within ' + range);
- return this;
- },
-
- /**
- * Assert typeof.
- *
- * @api public
- */
-
- a: function(type){
- this.assert(
- type == typeof this.obj
- , 'expected ' + this.inspect + ' to be a ' + type
- , 'expected ' + this.inspect + ' not to be a ' + type);
- return this;
- },
-
- /**
- * Assert instanceof.
- *
- * @api public
- */
-
- instanceof: function(constructor){
- var name = constructor.name;
- this.assert(
- this.obj instanceof constructor
- , 'expected ' + this.inspect + ' to be an instance of ' + name
- , 'expected ' + this.inspect + ' not to be an instance of ' + name);
- return this;
- },
-
- /**
- * Assert numeric value above _n_.
- *
- * @param {Number} n
- * @api public
- */
-
- above: function(n){
- this.assert(
- this.obj > n
- , 'expected ' + this.inspect + ' to be above ' + n
- , 'expected ' + this.inspect + ' to be below ' + n);
- return this;
- },
-
- /**
- * Assert numeric value below _n_.
- *
- * @param {Number} n
- * @api public
- */
-
- below: function(n){
- this.assert(
- this.obj < n
- , 'expected ' + this.inspect + ' to be below ' + n
- , 'expected ' + this.inspect + ' to be above ' + n);
- return this;
- },
-
- /**
- * Assert string value matches _regexp_.
- *
- * @param {RegExp} regexp
- * @api public
- */
-
- match: function(regexp){
- this.assert(
- regexp.exec(this.obj)
- , 'expected ' + this.inspect + ' to match ' + regexp
- , 'expected ' + this.inspect + ' not to match ' + regexp);
- return this;
- },
-
- /**
- * Assert property "length" exists and has value of _n_.
- *
- * @param {Number} n
- * @api public
- */
-
- length: function(n){
- this.obj.should.have.property('length');
- var len = this.obj.length;
- this.assert(
- n == len
- , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len
- , 'expected ' + this.inspect + ' to not have a length of ' + len);
- return this;
- },
-
- /**
- * Assert substring.
- *
- * @param {String} str
- * @api public
- */
-
- string: function(str){
- this.obj.should.be.a('string');
- this.assert(
- ~this.obj.indexOf(str)
- , 'expected ' + this.inspect + ' to include ' + i(str)
- , 'expected ' + this.inspect + ' to not include ' + i(str));
- return this;
- },
-
- /**
- * Assert property _name_ exists, with optional _val_.
- *
- * @param {String} name
- * @param {Mixed} val
- * @api public
- */
-
- property: function(name, val){
- if (this.negate && undefined !== val) {
- if (undefined === this.obj[name]) {
- throw new Error(this.inspect + ' has no property ' + i(name));
- }
- } else {
- this.assert(
- undefined !== this.obj[name]
- , 'expected ' + this.inspect + ' to have a property ' + i(name)
- , 'expected ' + this.inspect + ' to not have a property ' + i(name));
- }
-
- if (undefined !== val) {
- this.assert(
- val === this.obj[name]
- , 'expected ' + this.inspect + ' to have a property ' + i(name)
- + ' of ' + i(val) + ', but got ' + i(this.obj[name])
- , 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val));
- }
-
- this.obj = this.obj[name];
- return this;
- },
-
- /**
- * Assert own property _name_ exists.
- *
- * @param {String} name
- * @api public
- */
-
- ownProperty: function(name){
- this.assert(
- this.obj.hasOwnProperty(name)
- , 'expected ' + this.inspect + ' to have own property ' + i(name)
- , 'expected ' + this.inspect + ' to not have own property ' + i(name));
- return this;
- },
-
- /**
- * Assert that the array contains _obj_.
- *
- * @param {Mixed} obj
- * @api public
- */
-
- contain: function(obj){
- this.obj.should.be.an.instanceof(Array);
- this.assert(
- ~this.obj.indexOf(obj)
- , 'expected ' + this.inspect + ' to contain ' + i(obj)
- , 'expected ' + this.inspect + ' to not contain ' + i(obj));
- return this;
- },
-
- /**
- * Assert exact keys or inclusion of keys by using
- * the `.include` modifier.
- *
- * @param {Array|String ...} keys
- * @api public
- */
-
- keys: function(keys){
- var str
- , ok = true;
-
- keys = keys instanceof Array
- ? keys
- : Array.prototype.slice.call(arguments);
-
- if (!keys.length) throw new Error('keys required');
-
- var actual = Object.keys(this.obj)
- , len = keys.length;
-
- // Inclusion
- ok = keys.every(function(key){
- return ~actual.indexOf(key);
- });
-
- // Strict
- if (!this.negate && !this.includes) {
- ok = ok && keys.length == actual.length;
- }
-
- // Key string
- if (len > 1) {
- keys = keys.map(function(key){
- return i(key);
- });
- var last = keys.pop();
- str = keys.join(', ') + ', and ' + last;
- } else {
- str = i(keys[0]);
- }
-
- // Form
- str = (len > 1 ? 'keys ' : 'key ') + str;
-
- // Have / include
- str = (this.includes ? 'include ' : 'have ') + str;
-
- // Assertion
- this.assert(
- ok
- , 'expected ' + this.inspect + ' to ' + str
- , 'expected ' + this.inspect + ' to not ' + str);
-
- return this;
- },
-
- /**
- * Assert that _method_ is a function.
- *
- * @param {String} method
- * @api public
- */
-
- respondTo: function(method){
- this.assert(
- 'function' == typeof this.obj[method]
- , 'expected ' + this.inspect + ' to respond to ' + method + '()'
- , 'expected ' + this.inspect + ' to not respond to ' + method + '()');
- return this;
- }
-};
-
-/**
- * Aliases.
- */
-
-(function alias(name, as){
- Assertion.prototype[as] = Assertion.prototype[name];
- return alias;
-})
-('length', 'lengthOf')
-('keys', 'key')
-('ownProperty', 'haveOwnProperty')
-('above', 'greaterThan')
-('below', 'lessThan');
View
8 support/should.js/package.json
@@ -1,8 +0,0 @@
-{ "name": "should"
- , "description": "test framework agnostic BDD-style assertions"
- , "version": "0.0.4"
- , "author": "TJ Holowaychuk <tj@vision-media.ca>"
- , "keywords": ["test", "bdd", "assert"]
- , "main": "./lib/should.js"
- , "engines": { "node": ">= 0.2.0" }
-}
View
358 support/should.js/test/should.test.js
@@ -1,358 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var should = require('should');
-
-function err(fn, msg) {
- try {
- fn();
- should.fail('expected an error');
- } catch (err) {
- should.equal(msg, err.message);
- }
-}
-
-module.exports = {
- 'test .version': function(){
- should.version.should.match(/^\d+\.\d+\.\d+$/);
- },
-
- 'test double require': function(){
- require('should').should.equal(should);
- },
-
- 'test assertion': function(){
- 'test'.should.be.a.string;
- should.equal('foo', 'foo');
- },
-
- 'test true': function(){
- true.should.be.true;
- false.should.not.be.true;
- (1).should.not.be.true;
-
- err(function(){
- 'test'.should.be.true;
- }, "expected 'test' to be true")
- },
-
- 'test ok': function(){
- true.should.be.ok;
- false.should.not.be.ok;
- (1).should.be.ok;
- (0).should.not.be.ok;
-
- err(function(){
- ''.should.be.ok;
- }, "expected '' to be truthy");
-
- err(function(){
- 'test'.should.not.be.ok;
- }, "expected 'test' to be falsey");
- },
-
- 'test false': function(){
- false.should.be.false;
- true.should.not.be.false;
- (0).should.not.be.false;
-
- err(function(){
- ''.should.be.false;
- }, "expected '' to be false")
- },
-
- 'test arguments': function(){
- var args = (function(){ return arguments; })(1,2,3);
- args.should.be.arguments;
- [].should.not.be.arguments;
- },
-
- 'test .equal()': function(){
- var foo;
- should.equal(undefined, foo);
- },
-
- 'test typeof': function(){
- 'test'.should.be.a('string');
-
- err(function(){
- 'test'.should.not.be.a('string');
- }, "expected 'test' not to be a string");
-
- (5).should.be.a('number');
-
- err(function(){
- (5).should.not.be.a('number');
- }, "expected 5 not to be a number");
- },
-
- 'test instanceof': function(){
- function Foo(){}
- new Foo().should.be.an.instanceof(Foo);
-
- err(function(){
- (3).should.an.instanceof(Foo);
- }, "expected 3 to be an instance of Foo");
- },
-
- 'test within(start, finish)': function(){
- (5).should.be.within(5, 10);
- (5).should.be.within(3,6);
- (5).should.be.within(3,5);
- (5).should.not.be.within(1,3);
-
- err(function(){
- (5).should.not.be.within(4,6);
- }, "expected 5 to not be within 4..6");
-
- err(function(){
- (10).should.be.within(50,100);
- }, "expected 10 to be within 50..100");
- },
-
- 'test above(n)': function(){
- (5).should.be.above(2);
- (5).should.be.greaterThan(2);
- (5).should.not.be.above(5);
- (5).should.not.be.above(6);
-
- err(function(){
- (5).should.be.above(6);
- }, "expected 5 to be above 6");
-
- err(function(){
- (10).should.not.be.above(6);
- }, "expected 10 to be below 6");
- },
-
- 'test match(regexp)': function(){
- 'foobar'.should.match(/^foo/)
- 'foobar'.should.not.match(/^bar/)
-
- err(function(){
- 'foobar'.should.match(/^bar/i)
- }, "expected 'foobar' to match /^bar/i");
-
- err(function(){
- 'foobar'.should.not.match(/^foo/i)
- }, "expected 'foobar' not to match /^foo/i");
- },
-
- 'test length(n)': function(){
- 'test'.should.have.length(4);
- 'test'.should.not.have.length(3);
- [1,2,3].should.have.length(3);
-
- err(function(){
- (4).should.have.length(3);
- }, 'expected 4 to have a property \'length\'');
-
- err(function(){
- 'asd'.should.not.have.length(3);
- }, "expected 'asd' to not have a length of 3");
- },
-
- 'test eql(val)': function(){
- 'test'.should.eql('test');
- ({ foo: 'bar' }).should.eql({ foo: 'bar' });
- (1).should.eql(1);
- '4'.should.eql(4);
-
- err(function(){
- (4).should.eql(3);
- }, 'expected 4 to equal 3');
- },
-
- 'test equal(val)': function(){
- 'test'.should.equal('test');
- (1).should.equal(1);
-
- err(function(){
- (4).should.equal(3);
- }, 'expected 4 to equal 3');
-
- err(function(){
- '4'.should.equal(4);
- }, "expected '4' to equal 4");
- },
-
- 'test empty': function(){
- ''.should.be.empty;
- [].should.be.empty;
- ({ length: 0 }).should.be.empty;
-
- err(function(){
- ({}).should.be.empty;
- }, 'expected {} to have a property \'length\'');
-
- err(function(){
- 'asd'.should.be.empty;
- }, "expected 'asd' to be empty");
-
- err(function(){
- ''.should.not.be.empty;
- }, "expected '' not to be empty");
- },
-
- 'test property(name)': function(){
- 'test'.should.have.property('length');
- (4).should.not.have.property('length');
-
- err(function(){
- 'asd'.should.have.property('foo');
- }, "expected 'asd' to have a property 'foo'");
- },
-
- 'test property(name, val)': function(){
- 'test'.should.have.property('length', 4);
- 'asd'.should.have.property('constructor', String);
-
- err(function(){
- 'asd'.should.have.property('length', 4);
- }, "expected 'asd' to have a property 'length' of 4, but got 3");
-
- err(function(){
- 'asd'.should.not.have.property('length', 3);
- }, "expected 'asd' to not have a property 'length' of 3");
-
- err(function(){
- 'asd'.should.not.have.property('foo', 3);
- }, "'asd' has no property 'foo'");
-
- err(function(){
- 'asd'.should.have.property('constructor', Number);
- }, "expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String]");
- },
-
- 'test ownProperty(name)': function(){
- 'test'.should.have.ownProperty('length');
- 'test'.should.haveOwnProperty('length');
- ({ length: 12 }).should.have.ownProperty('length');
-
- err(function(){
- ({ length: 12 }).should.not.have.ownProperty('length');
- }, "expected { length: 12 } to not have own property 'length'");
- },
-
- 'test string()': function(){
- 'foobar'.should.include.string('bar');
- 'foobar'.should.include.string('foo');
- 'foobar'.should.not.include.string('baz');
-
- err(function(){
- (3).should.include.string('baz');
- }, "expected 3 to be a string");
-
- err(function(){
- 'foobar'.should.include.string('baz');
- }, "expected 'foobar' to include 'baz'");
-
- err(function(){
- 'foobar'.should.not.include.string('bar');
- }, "expected 'foobar' to not include 'bar'");
- },
-
- 'test contain()': function(){
- ['foo', 'bar'].should.contain('foo');
- ['foo', 'bar'].should.contain('foo');
- ['foo', 'bar'].should.contain('bar');
- [1,2].should.contain(1);
- ['foo', 'bar'].should.not.contain('baz');
- ['foo', 'bar'].should.not.contain(1);
-
- err(function(){
- ['foo'].should.contain('bar');
- }, "expected [ 'foo' ] to contain 'bar'");
-
- err(function(){
- ['bar', 'foo'].should.not.contain('foo');
- }, "expected [ 'bar', 'foo' ] to not contain 'foo'");
- },
-
- 'test keys(array)': function(){
- ({ foo: 1 }).should.have.keys(['foo']);
- ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']);
- ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar');
- ({ foo: 1, bar: 2, baz: 3 }).should.include.keys('foo', 'bar');
- ({ foo: 1, bar: 2, baz: 3 }).should.include.keys('bar', 'foo');
- ({ foo: 1, bar: 2, baz: 3 }).should.include.keys('baz');
-
- ({ foo: 1, bar: 2 }).should.include.keys('foo');
- ({ foo: 1, bar: 2 }).should.include.keys('bar', 'foo');
- ({ foo: 1, bar: 2 }).should.include.keys(['foo']);
- ({ foo: 1, bar: 2 }).should.include.keys(['bar']);
- ({ foo: 1, bar: 2 }).should.include.keys(['bar', 'foo']);
-
- ({ foo: 1, bar: 2 }).should.not.have.keys('baz');
- ({ foo: 1, bar: 2 }).should.not.have.keys('foo', 'baz');
- ({ foo: 1, bar: 2 }).should.not.include.keys('baz');
- ({ foo: 1, bar: 2 }).should.not.include.keys('foo', 'baz');
- ({ foo: 1, bar: 2 }).should.not.include.keys('baz', 'foo');
-
- err(function(){
- ({ foo: 1 }).should.have.keys();
- }, "keys required");
-
- err(function(){
- ({ foo: 1 }).should.have.keys([]);
- }, "keys required");
-
- err(function(){
- ({ foo: 1 }).should.not.have.keys([]);
- }, "keys required");
-
- err(function(){
- ({ foo: 1 }).should.include.keys([]);
- }, "keys required");
-
- err(function(){
- ({ foo: 1 }).should.have.keys(['bar']);
- }, "expected { foo: 1 } to have key 'bar'");
-
- err(function(){
- ({ foo: 1 }).should.have.keys(['bar', 'baz']);
- }, "expected { foo: 1 } to have keys 'bar', and 'baz'");
-
- err(function(){
- ({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']);
- }, "expected { foo: 1 } to have keys 'foo', 'bar', and 'baz'");
-
- err(function(){
- ({ foo: 1 }).should.not.have.keys(['foo']);
- }, "expected { foo: 1 } to not have key 'foo'");
-
- err(function(){
- ({ foo: 1 }).should.not.have.keys(['foo']);
- }, "expected { foo: 1 } to not have key 'foo'");
-
- err(function(){
- ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']);
- }, "expected { foo: 1, bar: 2 } to not have keys 'foo', and 'bar'");
-
- err(function(){
- ({ foo: 1 }).should.not.include.keys(['foo']);
- }, "expected { foo: 1 } to not include key 'foo'");
-
- err(function(){
- ({ foo: 1 }).should.include.keys('foo', 'bar');
- }, "expected { foo: 1 } to include keys 'foo', and 'bar'");
- },
-
- 'test respondTo(method)': function(){
- 'test'.should.respondTo('toString');
- 'test'.should.not.respondTo('toBuffer');
- },
-
- 'test chaining': function(){
- var user = { name: 'tj', pets: ['tobi', 'loki', 'jane', 'bandit'] };
- user.should.have.property('pets').with.lengthOf(4);
-
- err(function(){
- user.should.have.property('pets').with.lengthOf(5);
- }, "expected [ 'tobi', 'loki', 'jane', 'bandit' ] to have a length of 5 but got 4");
-
- user.should.be.a('object').and.have.property('name', 'tj');
- }
-};
View
2  test/collection.test.js
@@ -1,7 +1,7 @@
var start = require('./common')
, mongoose = start.mongoose
- , Collection = require('mongoose/collection');
+ , Collection = require('../lib/collection');
module.exports = {
View
4 test/document.test.js
@@ -8,7 +8,7 @@ var start = require('./common')
, mongoose = start.mongoose
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
- , Document = require('mongoose/document')
+ , Document = require('../lib/document')
, DocumentObjectId = mongoose.Types.ObjectId;
/**
@@ -520,7 +520,7 @@ module.exports = {
// GH-209
'MongooseErrors should be instances of Error': function () {
- var MongooseError = require('../lib/mongoose/error')
+ var MongooseError = require('../lib/error')
, err = new MongooseError("Some message");
err.should.be.an.instanceof(Error);
},
View
4 test/model.querying.test.js
@@ -6,8 +6,8 @@
var start = require('./common')
, should = require('should')
, mongoose = start.mongoose
- , random = require('mongoose/utils').random
- , Query = require('mongoose/query')
+ , random = require('../lib/utils').random
+ , Query = require('../lib/query')
, Schema = mongoose.Schema
, SchemaType = mongoose.SchemaType
, CastError = SchemaType.CastError
View
2  test/model.ref.test.js
@@ -6,7 +6,7 @@
var start = require('./common')
, should = require('should')
, mongoose = start.mongoose
- , random = require('mongoose/utils').random
+ , random = require('../lib/utils').random
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
View
4 test/model.test.js
@@ -6,8 +6,8 @@
var start = require('./common')
, should = require('should')
, mongoose = start.mongoose
- , random = require('mongoose/utils').random
- , Query = require('mongoose/query')
+ , random = require('../lib/utils').random
+ , Query = require('../lib/query')
, Schema = mongoose.Schema
, SchemaType = mongoose.SchemaType
, CastError = SchemaType.CastError
View
2  test/namedscope.test.js
@@ -26,7 +26,7 @@
var start = require('./common')
, should = require('should')
, mongoose = start.mongoose
- , random = require('mongoose/utils').random
+ , random = require('../lib/utils').random
, Schema = mongoose.Schema
, _24hours = 24 * 3600 * 1000;
View
2  test/promise.test.js
@@ -4,7 +4,7 @@
*/
var should = require('should')
- , Promise = require('mongoose/promise');
+ , Promise = require('../lib/promise');
/**
* Test.
View
2  test/query.test.js
@@ -3,7 +3,7 @@
* Module dependencies.
*/
-var Query = require('mongoose/query')
+var Query = require('../lib/query')
, start = require('./common')
, mongoose = start.mongoose
, DocumentObjectId = mongoose.Types.ObjectId
View
2  test/schema.onthefly.test.js
@@ -1,7 +1,7 @@
var start = require('./common')
, should = require('should')
, mongoose = start.mongoose
- , random = require('mongoose/utils').random
+ , random = require('../lib/utils').random
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId;
View
2  test/types.array.test.js
@@ -7,7 +7,7 @@ var start = require('./common')
, should = require('should')
, mongoose = require('./common').mongoose
, Schema = mongoose.Schema
- , random = require('mongoose/utils').random
+ , random = require('../lib/utils').random
, MongooseArray = mongoose.Types.Array;
var User = new Schema({
View
2  test/types.buffer.test.js
@@ -7,7 +7,7 @@ var start = require('./common')
, should = require('should')
, mongoose = require('./common').mongoose
, Schema = mongoose.Schema
- , random = require('mongoose/utils').random
+ , random = require('../lib/utils').random
, MongooseBuffer = mongoose.Types.Buffer;
// can't index Buffer fields yet
View
4 test/types.document.test.js
@@ -6,8 +6,8 @@
var should = require('should')
, start = require('./common')
, mongoose = start.mongoose
- , EmbeddedDocument = require('mongoose/types/document')
- , DocumentArray = require('mongoose/types/documentarray')
+ , EmbeddedDocument = require('../lib/types/document')
+ , DocumentArray = require('../lib/types/documentarray')
, Schema = mongoose.Schema
, SchemaType = mongoose.SchemaType
, ValidatorError = SchemaType.ValidatorError
View
5 test/types.documentarray.test.js
@@ -6,11 +6,10 @@
var mongoose = require('./common').mongoose
, MongooseArray = mongoose.Types.Array
, MongooseDocumentArray = mongoose.Types.DocumentArray
- , EmbeddedDocument = require('mongoose/types/document')
- , DocumentArray = require('mongoose/types/documentarray')
+ , EmbeddedDocument = require('../lib/types/document')
+ , DocumentArray = require('../lib/types/documentarray')
, Schema = mongoose.Schema
-
/**
* Setup.
*/
View
6 test/utils.test.js
@@ -5,9 +5,9 @@
require('./common');
-var utils = require('mongoose/utils')
- , StateMachine = require('mongoose/statemachine')
- , ObjectId = require('mongoose/types/objectid')
+var utils = require('../lib/utils')
+ , StateMachine = require('../lib/statemachine')
+ , ObjectId = require('../lib/types/objectid')
/**
* Setup.
Please sign in to comment.
Something went wrong with that request. Please try again.