Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Commit 4b2875b

Browse files
committed
Merge pull request #3 from mattpker/v1.1.1
v1.1.1: Fixed the tests to mock mongoose
2 parents 2c88101 + 62db5b8 commit 4b2875b

4 files changed

Lines changed: 27 additions & 11 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
22
node_js:
3+
- "0.12"
34
- "0.11"
45
- "0.10"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ Add unit tests for any new or changed functionality. Lint and test your code.
6666

6767
## Release History
6868

69+
* 1.1.1 Fixed the tests to mock mongoose
70+
* 1.1.0 Added option for changing the collection
6971
* 1.0.0 Initial release

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "is-master",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Find the master node process in a multi server cluster.",
55
"main": "is-master.js",
66
"scripts": {
@@ -32,7 +32,13 @@
3232
"homepage": "https://github.com/mattpker/node-is-master",
3333
"devDependencies": {
3434
"chai": "^1.10.0",
35+
"install": "^0.1.8",
3536
"mocha": "^2.1.0",
36-
"mongoose": "^3.8.22"
37+
"mongoose": "^4.0.6",
38+
"mongoose-mock": "^0.4.0",
39+
"npm": "^2.12.1",
40+
"proxyquire": "^1.6.0",
41+
"sinon": "^1.15.4",
42+
"sinon-chai": "^2.8.0"
3743
}
3844
}

test/is-master.spec.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
'use strict';
22

3-
var expect = require("../node_modules/chai").expect;
3+
var chai = require("../node_modules/chai");
4+
var expect = chai.expect;
45
var mongoose = require('../node_modules/mongoose');
5-
var im = require('../is-master.js');
6+
var mongooseMock = require('mongoose-mock');
7+
var proxyquire = require('proxyquire');
8+
var sinon = require('sinon');
9+
var sinonChai = require("sinon-chai");
610

7-
// Bootstrap db connection
8-
mongoose.connect('mongodb://127.0.0.1:27017/im', function(err) {
9-
if (err) {
10-
console.error('\x1b[31m', 'Could not connect to MongoDB!');
11-
throw (err);
12-
}
13-
});
11+
chai.use(sinonChai);
1412

1513
describe("is-master", function() {
14+
15+
var im;
16+
17+
beforeEach(function() {
18+
im = proxyquire('../is-master.js', {
19+
'mongoose': mongooseMock
20+
});
21+
});
22+
1623
it("should start the worker", function(done) {
1724
im.start({
1825
collection: 'testcol',

0 commit comments

Comments
 (0)