Skip to content

Instantly share code, notes, and snippets.

var kiwi = require("kiwi")
kiwi.require("NoSpec")
new NoSpec()
.define("myLibrary", __dirname + "/lib/myLib", "myLib")
// => var myLibrary = require(__dirname + "/lib/myLib").myLib
.load(__dirname + "/specFile")
.load(__dirname + "/anotherSpecFile")
.load(__dirname + "/specFolder")
// use this to load all files in a folder and its subfolders
// the basic structure
describe("the class you want to test", function() {
describe("a function you want to test", function() {
it("should do something", function() {
// your nice test code here
})
})
})
// some more practical
exports.MyLib = function(name){
this.name = name
}
exports.MyLib.prototype.sayHello = function() {
return "Hello " + this.name
}
var kiwi = require("kiwi")
kiwi.require("NoSpec")
new NoSpec()
.define("myLib", __dirname + "/../lib/myLib", "MyLib")
.load(__dirname + "/myLibSpec")
.run()
describe("MyLib", function() {
describe("sayHello", function() {
it("should return hello + name", function() {
var libInstance = new MyLib("Jane")
expect(libInstance.sayHello()).toEqual("Hello Jane")
})
})
})
describe("comparison methods", function() {
it("should do smth with toEqual", function () {
expect("a").toEqual("a") // will be true
expect("a").toEqual("b") // will be false
var hash = {a: 1}
expect(hash).toEqual(hash) // will be true
expect(hash).toEqual({a: 1}) // will be false
})
describe("before", function() {
before(function() {
var hash = {a: 1}
var foo = "a"
})
it("should correctly use before", function() {
expect(hash).toMatch({a: 1}) // will be true
hash.a = 2
expect(hash).toMatch({a: 2}) // will be true
ec2-add-keypair <name>-keypair
# copy the result to ./~ssh/id_rsa-<name>-keypair
chmod 700 ./~ssh/id_rsa-<name>-keypair
ec2-run-instances <instance-identifier, e.g.: ami-0d729464> -k <name>-keypair
# copy the value behind INSTANCE (should be smth. like i-64d4c00f)
ec2-describe-instances <copied value> (refresh until instance has booted)
# once it's running you will get an url which we use for ssh
ssh -i ~/.ssh/id_rsa-<name>-keypair root@<url>
var tags = tags_text.split(',');
var errors = [];
if (errors.length > 0) {
} else {
var new_question = new db.Question({
title: title,
body: body,
doNotify: doNotify,
@sdepold
sdepold / JSMasterclass
Created October 19, 2010 18:20
Closures
// Exercise 2 - Closures
// Wrap the following code in a closure and export only the "countdown" function.
// Code
(function(name, obj) {
var index;
function log(){
console.log(index);