Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Don't directly depend on components to wire
Browse files Browse the repository at this point in the history
Change API from magical side-effect require to exporting a function that
accepts the modules to wire together. The module now has no
dependencies, instead you pass in the components to wire up. This also
allows using a specific instance of e.g. stack-filter.
  • Loading branch information
cjohansen committed Apr 14, 2013
1 parent 35ff070 commit c805077
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
69 changes: 33 additions & 36 deletions lib/buster-sinon.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
((typeof define === "function" && define.amd && function (m) {
define(["sinon", "buster-test", "stack-filter", "formatio"], m);
define(m);
}) || (typeof module === "object" &&
typeof require === "function" && function (m) {
module.exports = m(
require("sinon"),
require("buster-test"),
require("stack-filter"),
require("formatio")
);
module.exports = m();
}) || function (m) {
m(this.sinon, this.buster, this.stackFilter, this.formatio);
this.busterSinon = m();
}
)(function (sinon, bt, stackFilter, formatio) {
stackFilter.filters.push("lib/sinon");
)(function () {
return function (sinon, bt, stackFilter, formatio) {
stackFilter.filters.push("lib/sinon");

bt.testRunner.onCreate(function (runner) {
runner.on("test:setUp", function (test) {
var config = sinon.getConfig(sinon.config);
config.useFakeServer = false;
var sandbox = sinon.sandbox.create();
sandbox.inject(test.testCase);
bt.testRunner.onCreate(function (runner) {
runner.on("test:setUp", function (test) {
var config = sinon.getConfig(sinon.config);
config.useFakeServer = false;
var sandbox = sinon.sandbox.create();
sandbox.inject(test.testCase);

test.testCase.useFakeTimers = function () {
return sandbox.useFakeTimers.apply(sandbox, arguments);
};
test.testCase.useFakeTimers = function () {
return sandbox.useFakeTimers.apply(sandbox, arguments);
};

test.testCase.useFakeServer = function () {
return sandbox.useFakeServer.apply(sandbox, arguments);
};
test.testCase.useFakeServer = function () {
return sandbox.useFakeServer.apply(sandbox, arguments);
};

test.testCase.sandbox = sandbox;
var testFunc = test.func;
});
test.testCase.sandbox = sandbox;
var testFunc = test.func;
});

runner.on("test:tearDown", function (test) {
try {
test.testCase.sandbox.verifyAndRestore();
} catch (e) {
runner.assertionFailure(e);
}
});
runner.on("test:tearDown", function (test) {
try {
test.testCase.sandbox.verifyAndRestore();
} catch (e) {
runner.assertionFailure(e);
}
});

sinon.expectation.pass = function () {
runner.assertionPass();
};
});
sinon.expectation.pass = function () {
runner.assertionPass();
};
});
};
});
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
"scripts": {
"test": "./run-tests"
},
"dependencies": {
"devDependencies": {
"referee": "~0.11",
"buster-test": "~0.7",
"formatio": "~0.6",
"sinon": "~1.4",
"stack-filter": "~0.1"
},
"devDependencies": {
"referee": "~0.11"
}
}
7 changes: 6 additions & 1 deletion test/buster-sinon-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
require("../lib/buster-sinon");
var buster = require("buster-test");
require("../lib/buster-sinon")(
require("sinon"),
buster,
require("stack-filter"),
require("formatio")
);
var referee = require("referee");
var assert = referee.assert;
var refute = referee.refute;
Expand Down

0 comments on commit c805077

Please sign in to comment.