Skip to content

Instantly share code, notes, and snippets.

define(['module/bootstrap'], function(news) {
var $ = news.$;
function seconds(secs) {
return secs * 1000;
}
function double(num) {
return num * 2;
}
# - I've assumed you've separated the items into two arrays
# because you want to select those items at some point later.
# I've refactored to 'filter' the items on the way out, rather
# than filtering them on the way in.
# - Also added a :type method rather than class checking.
# - You could even use Set instead of [] here
class Foo
def initialize(initial_items = [])
@items = initial_items

The problem with Faking it

The Problem

Developer (A) creates 2 classes, MyClass and Dependency:

class MyClass
{
    private $dependency;
@danscotton
danscotton / gist:3164620
Created July 23, 2012 16:41 — forked from froots/gist:3164377
mocking with amd
// ----------------------------------------
// /path/to/dependency.js
define(function() {
return {
doSomethingWithIt: function() {
// blah
}
};
});