Comparing version 1.2.0 to 1.3.1
@@ -34,3 +34,3 @@ /*! | ||
void function () { | ||
var abbreviate, asRegExp, assert, cache$, contains, error, global, green, handleArgs, implodeNicely, isArray, isEqual, isNumber, isRegExp, isString, name, nameNegative, red, stringify, toString, type; | ||
var abbreviate, asRegExp, assert, cache$, clear, contains, error, global, green, handleArgs, implodeNicely, isArray, isEqual, isNumber, isRegExp, isString, name, nameNegative, red, stringify, toString, type; | ||
global = Function('return this')(); | ||
@@ -132,3 +132,3 @@ cache$ = null != global._ ? global._ : require('underscore'); | ||
include: function (needle, haystack) { | ||
var cache$1, cache$2, contained, explanation, message, name, negated, problem, verb; | ||
var cache$1, cache$2, contained, explanation, message, name, negated, problem, verb, what; | ||
cache$1 = handleArgs(this, [ | ||
@@ -148,2 +148,6 @@ 2, | ||
if (isString(haystack)) { | ||
if (needle === '') { | ||
what = negated ? 'always-failing test' : 'no-op test'; | ||
throw error('' + what + ' detected: all strings contain the empty string!'); | ||
} | ||
if (!(isString(needle) || isNumber(needle) || isRegExp(needle))) { | ||
@@ -157,6 +161,2 @@ problem = 'needs a RegExp/String/Number needle for a String haystack'; | ||
} | ||
if (haystack.length === 0 && !negated) | ||
if (!(isString(haystack) && isRegExp(needle))) { | ||
throw error('' + red(stringify(haystack)) + ' will never include anything'); | ||
} | ||
if (isString(haystack)) { | ||
@@ -290,2 +290,3 @@ if (isRegExp(needle)) { | ||
}; | ||
clear = '\x1b[39;49;00m'; | ||
implodeNicely = function (list, conjunction) { | ||
@@ -369,3 +370,3 @@ var first, last; | ||
if (null != explanation) | ||
message = 'Assertion failed: ' + explanation + '\n' + message; | ||
message = 'Assertion failed: ' + explanation + '\n' + clear + message; | ||
return new Error(message); | ||
@@ -372,0 +373,0 @@ }; |
{ "name": "assertive" | ||
, "version": "1.2.0" | ||
, "version": "1.3.1" | ||
, "author": "Johan Sundström <jsundstrom@groupon.com>" | ||
@@ -21,2 +21,4 @@ , "contributors": | ||
{ "mocha": "1.8.2" | ||
, "semver": "2.1.0" | ||
, "format-json": "1.0.2" | ||
, "coffee-script-redux": "2.0.0-beta7" | ||
@@ -23,0 +25,0 @@ } |
@@ -21,2 +21,21 @@ assertive | ||
Semantic Versioning | ||
---------------------------------------------------------------------- | ||
Assertive uses [semver](http://semver.org/) version numbers, though we | ||
should point out that we may tighten assertion checks in minor version | ||
number updates, making code that previously silently passed, now fail. | ||
Case in point: before v1.3.0, code using an assertion to verify that a | ||
string included the empty string, would do just that. In other words - | ||
nothing, since that assertion does not test anything. Now, such a test | ||
is flagged as a bug in your test suite that you should fix, as that is | ||
not asserting something about your code, but about strings in general. | ||
In Assertive, breaking changes implying a major version bump, would be | ||
things like argument order changes. If you really do not want improved | ||
coverage against this type of error with a random minor version update | ||
you should pin a version you like in your `package.json` rather than a | ||
version range. | ||
Usage | ||
@@ -23,0 +42,0 @@ ---------------------------------------------------------------------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
148
54703
4
9
418