Skip to content

Instantly share code, notes, and snippets.

@mandric
Created December 19, 2011 17:33
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 mandric/1498086 to your computer and use it in GitHub Desktop.
Save mandric/1498086 to your computer and use it in GitHub Desktop.
// passes in couchbase single server, you can test in Futon by pasting into Custom Test
couchTests.custom_test = function(debug) {
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();
if (debug) debugger;
var testregexDoc = {
_id: "_design/testregex",
"shows" : {
"newexec" : "function(doc) {\
var re = new RegExp('test'); return re.exec('testing')[0];\
}",
"newtest" : "function(doc) {\
var re = new RegExp('test'); return String(re.test('testing'));\
}"
}
};
var save_response = db.save(testregexDoc);
T(save_response.ok);
var xhr = CouchDB.request("GET", "/test_suite_db/_design/testregex/_show/newexec");
T(xhr.responseText === "test");
xhr = CouchDB.request("GET", "/test_suite_db/_design/testregex/_show/newtest");
T(xhr.responseText === "true");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment