Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit816cdbe

Browse files
committed
Added istanbul for test coverage
1 parent125d7e2 commit816cdbe

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

‎.istanbul.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instrumentation:
2+
# __get__ and __set__ will be stringified and evaled again. Thus it's difficult to include them into the test coverage
3+
excludes:['lib/__get__.js', 'lib/__set__.js']

‎.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ language: node_js
22
node_js:
33
-"0.8"
44
-"0.10"
5+
-"0.11"
56

67
script:
7-
-npm test
8+
-npm test
9+
after_success:
10+
-npm install -g istanbul
11+
-npm install coveralls
12+
-istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

‎README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rewire
22
=====
3-
**Dependencyinjection for node.jsapplications**.
3+
**Easy dependencyinjection for node.jsunit testing**.
44

55
rewire adds a special setter and getter to modules so you can modify their behaviour for better unit testing. You may
66

@@ -17,8 +17,9 @@ case CoffeeScript needs to be listed in your devDependencies.
1717

1818
If you want to use rewire also on the client-side take a look at[client-side bundlers](https://github.com/jhnns/rewire#client-side-bundlers)
1919

20-
[![Build Status](https://secure.travis-ci.org/jhnns/rewire.png?branch=master)](http://travis-ci.org/jhnns/rewire)
21-
[![Dependency Status](https://david-dm.org/jhnns/rewire/status.png)](http://david-dm.org/jhnns/rewire)
20+
[![Build Status](https://travis-ci.org/jhnns/rewire.svg?branch=master)](http://travis-ci.org/jhnns/rewire)
21+
[![Dependency Status](https://david-dm.org/jhnns/rewire.svg)](https://david-dm.org/jhnns/rewire)
22+
[![Coverage Status](https://coveralls.io/repos/jhnns/rewire/badge.png)](https://coveralls.io/r/jhnns/rewire)
2223

2324
<br />
2425

‎lib/rewire.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ var Module = require("module"),
66
detectStrictMode=require("./detectStrictMode.js"),
77
moduleEnv=require("./moduleEnv.js");
88

9+
var__get__Src=__get__.toString(),
10+
__set__Src=__set__.toString();
11+
912
/**
1013
* Does actual rewiring the module. For further documentation @see index.js
1114
*/
@@ -26,6 +29,7 @@ function internalRewire(parentModulePath, targetPath) {
2629
// Special support for older node versions that returned an array on Module._resolveFilename
2730
//@see https://github.com/joyent/node/blob/865b077819a9271a29f982faaef99dc635b57fbc/lib/module.js#L319
2831
// TODO Remove this switch on the next major release
32+
/* istanbul ignore next because it will be removed soon */
2933
if(Array.isArray(targetPath)){
3034
targetPath=targetPath[1];
3135
}
@@ -38,8 +42,8 @@ function internalRewire(parentModulePath, targetPath) {
3842

3943
// We append our special setter and getter.
4044
appendix="\n";
41-
appendix+="module.exports.__set__ = "+__set__.toString()+"; ";
42-
appendix+="module.exports.__get__ = "+__get__.toString()+"; ";
45+
appendix+="module.exports.__set__ = "+__set__Src+"; ";
46+
appendix+="module.exports.__get__ = "+__get__Src+"; ";
4347

4448
// Check if the module uses the strict mode.
4549
// If so we must ensure that "use strict"; stays at the beginning of the module.

‎test/testModules/fake_node_modules/rewire/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/testModules/module.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
fs=require"fs"
1+
fs=require"fs"
22

33
exports.readFileSync= ()->fs.readFileSync()

‎test/testModules/sharedTestCases.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,9 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
175175
}
176176
}
177177
});
178+
it("should throw a TypeError if the path is not a string",function(){
179+
expect(function(){
180+
rewire(null);
181+
}).to.throwException(checkForTypeError);
182+
});
178183
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp