assertive-as-promised
Advanced tools
Comparing version 0.1.0 to 1.0.0
@@ -1,2 +0,3 @@ | ||
// Generated by CoffeeScript 1.6.3 | ||
// Generated by CoffeeScript 1.9.3 | ||
/* | ||
@@ -32,10 +33,9 @@ Copyright (c) 2014, Groupon, Inc. | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
*/ | ||
var Promise, aap, assert, clear, emsg, fn, fn1, green, isPromiseAlike, name, red, | ||
slice = [].slice, | ||
hasProp = {}.hasOwnProperty; | ||
var Q, aap, assert, clear, emsg, fn, green, name, red, _fn, | ||
__slice = [].slice, | ||
__hasProp = {}.hasOwnProperty; | ||
Promise = require('bluebird'); | ||
Q = require('q'); | ||
assert = require('assertive'); | ||
@@ -62,4 +62,8 @@ | ||
isPromiseAlike = function(p) { | ||
return p === Object(p) && 'function' === typeof p.then; | ||
}; | ||
aap.rejects = function(expln, testee, name) { | ||
var _ref; | ||
var ref; | ||
if (name == null) { | ||
@@ -71,9 +75,9 @@ name = 'rejects'; | ||
} else { | ||
_ref = [expln, null], testee = _ref[0], expln = _ref[1]; | ||
ref = [expln, null], testee = ref[0], expln = ref[1]; | ||
} | ||
if (!Q.isPromiseAlike(testee)) { | ||
if (!isPromiseAlike(testee)) { | ||
if ('function' !== typeof testee) { | ||
throw new Error("" + name + " expects " + (green('a function or promise')) + " but got " + (red(testee))); | ||
throw new Error(name + " expects " + (green('a function or promise')) + " but got " + (red(testee))); | ||
} | ||
testee = Q["try"](testee); | ||
testee = Promise["try"](testee); | ||
} | ||
@@ -88,4 +92,4 @@ if (name === 'rejects') { | ||
return testee["catch"](function(err) { | ||
var _ref1; | ||
throw new Error(emsg("Promise was rejected despite resolves assertion:\n" + ((_ref1 = err != null ? err.message : void 0) != null ? _ref1 : err), expln)); | ||
var ref1; | ||
throw new Error(emsg("Promise was rejected despite resolves assertion:\n" + ((ref1 = err != null ? err.message : void 0) != null ? ref1 : err), expln)); | ||
}); | ||
@@ -99,6 +103,6 @@ } | ||
_fn = function(name, fn) { | ||
fn1 = function(name, fn) { | ||
return aap[name] != null ? aap[name] : aap[name] = function() { | ||
var args, testee; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
if (!args.length) { | ||
@@ -108,8 +112,8 @@ return fn(); | ||
testee = args.pop(); | ||
if (Q.isPromiseAlike(testee)) { | ||
if (isPromiseAlike(testee)) { | ||
return testee.then(function(val) { | ||
return fn.apply(null, __slice.call(args).concat([val])); | ||
return fn.apply(null, slice.call(args).concat([val])); | ||
}); | ||
} else { | ||
return fn.apply(null, __slice.call(args).concat([testee])); | ||
return fn.apply(null, slice.call(args).concat([testee])); | ||
} | ||
@@ -119,5 +123,5 @@ }; | ||
for (name in assert) { | ||
if (!__hasProp.call(assert, name)) continue; | ||
if (!hasProp.call(assert, name)) continue; | ||
fn = assert[name]; | ||
_fn(name, fn); | ||
fn1(name, fn); | ||
} | ||
@@ -124,0 +128,0 @@ |
{ | ||
"name": "assertive-as-promised", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Extends assertive with promise support", | ||
@@ -12,15 +12,18 @@ "main": "lib/aap.js", | ||
"prepublish": "./node_modules/.bin/coffee -bcps < src/aap.coffee > lib/aap.js.tmp && mv -f lib/aap.js.tmp lib/aap.js || (rm -f lib/aap.js.tmp ; false)", | ||
"test": "npm install && ./node_modules/.bin/mocha -R spec --compilers coffee:coffee-script/register test" | ||
"test": "npm install && ./node_modules/.bin/mocha" | ||
}, | ||
"publishConfig": { | ||
"registry": "http://registry.npmjs.org" | ||
}, | ||
"author": "David Bushong <david+npm@bushong.net>", | ||
"license": "BSD", | ||
"license": "BSD-3-Clause", | ||
"dependencies": { | ||
"q": "~1.0.0", | ||
"assertive": "~1.3.2" | ||
"assertive": "^1.3.2", | ||
"bluebird": "^2.9.34" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "~1.7.1", | ||
"mocha": "~1.17.1", | ||
"mocha-as-promised": "~2.0.0" | ||
"assertive-as-promised": "*", | ||
"coffee-script": "^1.7.1", | ||
"mocha": "^1.18.0" | ||
} | ||
} |
@@ -9,5 +9,6 @@ # Assertive for Promises | ||
This is best used with something like [Mocha as Promised][]. All of | ||
assertive's assertions are extended to accept promises as their argument to be | ||
tested and return a promise which will be resolved or rejected. | ||
This is best used with something like [Mocha] (version >= 1.18.0) which | ||
handles returned promises correctly. All of assertive's assertions are | ||
extended to accept promises as their argument to be tested and return a | ||
promise which will be resolved or rejected. | ||
@@ -78,3 +79,8 @@ For all existing assertive functions, you may simply replace the | ||
## Development | ||
* `src/aap.coffee` is the main library; it compiles to `lib/aap.js`. | ||
* `test/assertive_test.coffee` is a copy of the [assertive] library tests, slightly modified to run correctly in our test environment (see comments at the top) | ||
[assertive]: https://github.com/groupon/assertive | ||
[Mocha as Promised]: https://github.com/domenic/mocha-as-promised | ||
[Mocha]: https://mochajs.org/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
10
0
1
85
41359
108
+ Addedbluebird@^2.9.34
+ Addedassertive@1.4.1(transitive)
+ Addedbluebird@2.11.0(transitive)
- Removedq@~1.0.0
- Removedassertive@1.3.2(transitive)
- Removedq@1.0.1(transitive)
Updatedassertive@^1.3.2