Skip to content

Instantly share code, notes, and snippets.

@sdepold
sdepold / app.js
Last active August 29, 2015 14:13
Multi instance setup for sequelize
var dbAdmin = require('./db/admin.js');
var dbNormal = require('./db/normal.js');
var dbSomethingElse = require('./db/something-else.js');
describe("MyLib", function() {
describe("sayHello", function() {
it("should return hello + name", function() {
var libInstance = new MyLib("Jane")
expect(libInstance.sayHello()).toEqual("Hello Jane")
})
})
})
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
var kiwi = require("kiwi")
kiwi.require("NoSpec")
new NoSpec()
.define("myLib", __dirname + "/../lib/myLib", "MyLib")
.load(__dirname + "/myLibSpec")
.run()
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
})
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
}
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,