sinon-chai
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -63,4 +63,4 @@ (function (sinonChai) { | ||
function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) { | ||
utils.addMethod(chai.Assertion.prototype, chaiName, function () { | ||
function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) { | ||
return function () { | ||
assertCanWorkWith(this); | ||
@@ -74,5 +74,15 @@ | ||
this.assert(this._obj[sinonMethod].apply(this._obj, arguments), messages.affirmative, messages.negative); | ||
}); | ||
}; | ||
} | ||
function sinonMethodAsProperty(name, action, nonNegatedSuffix) { | ||
var handler = createSinonMethodHandler(name, action, nonNegatedSuffix); | ||
utils.addProperty(chai.Assertion.prototype, name, handler); | ||
} | ||
function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) { | ||
var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix); | ||
utils.addMethod(chai.Assertion.prototype, chaiName, handler); | ||
} | ||
function sinonMethod(name, action, nonNegatedSuffix) { | ||
@@ -90,2 +100,3 @@ exceptionalSinonMethod(name, name, action, nonNegatedSuffix); | ||
sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C"); | ||
sinonMethodAsProperty("calledWithNew", "been called with new"); | ||
sinonMethod("calledBefore", "been called before %1"); | ||
@@ -92,0 +103,0 @@ sinonMethod("calledAfter", "been called after %1"); |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)", | ||
@@ -18,3 +18,3 @@ "license": "WTFPL", | ||
"type": "git", | ||
"url": "https://github.com/domenic/sinon-chai" | ||
"url": "git://github.com/domenic/sinon-chai.git" | ||
}, | ||
@@ -30,18 +30,16 @@ "bugs": { | ||
"test": "mocha", | ||
"lint": "jshint ./lib --show-non-errors", | ||
"cover": "cover run node_modules/mocha/bin/_mocha && cover report html && start ./cover_html/index.html" | ||
"lint": "jshint ./lib", | ||
"cover": "cover run node_modules/mocha/bin/_mocha && cover report html && opener ./cover_html/index.html" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"dependencies": { | ||
"sinon": ">=1.3.4 <2" | ||
"sinon": ">=1.5 <2" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "1", | ||
"mocha": "1", | ||
"chai": "1", | ||
"cover": "*", | ||
"jshint": ">= 0.7.1" | ||
"chai": ">= 1.3.0", | ||
"coffee-script": ">= 1.4.0", | ||
"cover": ">= 0.2.8", | ||
"jshint": ">= 0.9.1", | ||
"mocha": ">= 1.7.0", | ||
"opener": ">= 1.3.0" | ||
} | ||
} |
Sinon.JS Assertions for Chai | ||
============================ | ||
**Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][sinon] spy, stub, and mocking framework | ||
with the [Chai][chai] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS. | ||
**Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][] spy, stub, and mocking framework with the | ||
[Chai][] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS. | ||
@@ -62,2 +62,10 @@ Instead of using Sinon.JS's assertions: | ||
<tr> | ||
<td>calledWithNew</td> | ||
<td>spy.should.have.been.calledWithNew</td> | ||
</tr> | ||
<tr> | ||
<td>alwaysCalledWithNew</td> | ||
<td>spy.should.always.have.been.calledWithNew</td> | ||
</tr> | ||
<tr> | ||
<td>calledOn</td> | ||
@@ -122,3 +130,3 @@ <td>spy.should.have.been.calledOn(context)</td> | ||
You can of course put this code in a common test fixture file; for an example using [Mocha][mocha], see | ||
You can of course put this code in a common test fixture file; for an example using [Mocha][], see | ||
[the Sinon–Chai tests themselves][fixturedemo]. | ||
@@ -128,4 +136,4 @@ | ||
Sinon–Chai supports being used as an [AMD][amd] module, registering itself anonymously (just like Chai). So, assuming | ||
you have configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `"chai"` and | ||
Sinon–Chai supports being used as an [AMD][] module, registering itself anonymously (just like Chai). So, assuming you | ||
have configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `"chai"` and | ||
`"sinon-chai"`, you can use them as follows: | ||
@@ -145,3 +153,3 @@ | ||
If you include Sinon–Chai directly with a `<script>` tag, after the one for Chai itself, then it will automatically plug | ||
in to Chai and be ready for use: | ||
in to Chai and be ready for use. Note that you'll want to get the latest browser build of Sinon.JS as well: | ||
@@ -151,10 +159,17 @@ ```html | ||
<script src="sinon-chai.js"></script> | ||
<script src="sinon.js"></script> | ||
``` | ||
### Ruby on Rails | ||
[sinon]: http://sinonjs.org/ | ||
[chai]: http://chaijs.com/ | ||
[mocha]: http://visionmedia.github.com/mocha/ | ||
Thanks to [Cymen Vig][], there's now [a Ruby gem][] of Sinon–Chai that integrates it with the Rails asset pipeline! | ||
[Sinon.JS]: http://sinonjs.org/ | ||
[Chai]: http://chaijs.com/ | ||
[spymethods]: http://sinonjs.org/docs/#spies-api | ||
[Mocha]: http://visionmedia.github.com/mocha/ | ||
[fixturedemo]: https://github.com/domenic/sinon-chai/tree/master/test/ | ||
[spymethods]: http://sinonjs.org/docs/#spies-api | ||
[amd]: https://github.com/amdjs/amdjs-api/wiki/AMD | ||
[AMD]: https://github.com/amdjs/amdjs-api/wiki/AMD | ||
[Cymen Vig]: https://github.com/cymen | ||
[a Ruby gem]: https://github.com/cymen/sinon-chai-rails |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
10876
87
171
6
1
Updatedsinon@>=1.5 <2