Skip to content

Instantly share code, notes, and snippets.

@abovethewater
Forked from luciferous/node-jsmockito.sh
Created March 6, 2012 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abovethewater/1984875 to your computer and use it in GitHub Desktop.
Save abovethewater/1984875 to your computer and use it in GitHub Desktop.
JSHamcrest 0.6.7 - Use JsMockito with NodeJS (patched for CommonJS Module 1.1 compliance)
#!/bin/sh
# JsHamcrest v0.6.7 && JsMockito v1.0.4
# 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,2353
>
> exports.JsMockito = {};
> JsMockito.Integration.importTo(exports.JsMockito);
>
> exports.JsHamcrest = {};
> JsHamcrest.Integration.copyMembers(exports.JsHamcrest);
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment