Created
September 19, 2011 21:45
-
-
Save luciferous/1227705 to your computer and use it in GitHub Desktop.
Use JsMockito with NodeJS (patched for CommonJS Module 1.1 compliance)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Begin with an empty file. | |
echo > mockito.js | |
# Download and concatenate jshamcrest with jsmockito. | |
curl --silent --compressed \ | |
http://jshamcrest.destaquenet.com/jshamcrest.js \ | |
http://cloud.github.com/downloads/chrisleishman/jsmockito/jsmockito-1.0.4.js \ | |
> mockito.js | |
# Patch a few things: | |
# - Compliance with CommonJS Module 1.1 specification | |
# - Throw Error objects instead of String objects | |
# - Declare JsMockito locally using `var` | |
patch mockito.js <<EOF | |
1646c1646 | |
< JsMockito = { | |
--- | |
> var JsMockito = { | |
2235c2235 | |
< throw description.get(); | |
--- | |
> throw new Error(description.get()); | |
2266c2266 | |
< throw description.get(); | |
--- | |
> throw new Error(description.get()); | |
2347a2348,2352 | |
> exports.JsMockito = {}; | |
> JsMockito.Integration.importTo(exports.JsMockito); | |
> | |
> exports.JsHamcrest = {}; | |
> JsHamcrest.Integration.copyMembers(exports.JsHamcrest); | |
EOF |
echo the thanks - created fork for latest (v0.6.7) version of JsHamcrest.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, this was useful.