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
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 |
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
// 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 |
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
exports.MyLib = function(name){ | |
this.name = name | |
} | |
exports.MyLib.prototype.sayHello = function() { | |
return "Hello " + this.name | |
} |
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
var kiwi = require("kiwi") | |
kiwi.require("NoSpec") | |
new NoSpec() | |
.define("myLib", __dirname + "/../lib/myLib", "MyLib") | |
.load(__dirname + "/myLibSpec") | |
.run() |
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
describe("MyLib", function() { | |
describe("sayHello", function() { | |
it("should return hello + name", function() { | |
var libInstance = new MyLib("Jane") | |
expect(libInstance.sayHello()).toEqual("Hello Jane") | |
}) | |
}) | |
}) |
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
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 | |
}) |
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
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 |
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
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> |
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
var tags = tags_text.split(','); | |
var errors = []; | |
if (errors.length > 0) { | |
} else { | |
var new_question = new db.Question({ | |
title: title, | |
body: body, | |
doNotify: doNotify, |
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
// 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); |
OlderNewer