Permalink
Browse files

Updated README docs.

  • Loading branch information...
1 parent ad3572e commit bff581caa049b1595ccb5c2e2ca7e493a463a527 @easternbloc committed Feb 10, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 README.md
View
@@ -1,3 +1,4 @@
+
Syringe
=======
@@ -21,6 +22,36 @@ To properly unit test your code you need mock all the modules and methods your m
npm install syringe
+## API
+#### inject
+ module.inject('method', function() {
+ // mock code here
+ });
+#### forceInject
+ module.forceInject('methodThatDoesntExistOnTheAPINatively', function() {
+ // mock code here
+ });
+#### restore
+ module.restore('method');
+#### wrap
+ module.wrap('method', function() {
+ // code to run before the method is called
+ called = true;
+ });
+#### unWrap
+ module.unWrap('method');
+#### replaceAll
+ var stubbedUtil = {
+ print: function() {
+ methodCalled = true;
+ }
+ };
+ module.replaceAll(stubbedUtil);
+#### restoreAll
+ module.restoreAll();
+
+## Example
+
In order to unit test this module properly, you need to mock functions in the dns and url modules. Syringe lets you inject directly over the top of modules or selectively mock the methods in them you're using.
var dns = require('./dns');

0 comments on commit bff581c

Please sign in to comment.