Skip to content

Instantly share code, notes, and snippets.

@naganowl
naganowl / index.html
Created November 23, 2016 19:58
Barebones Jasmine HTML spec runner (assuming test directory and properly named files)
<!doctype html>
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
</head>
<body>
<script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
@naganowl
naganowl / yarn-install.sh
Created November 16, 2016 00:38
Use versioned yarn install from tarball
wget https://yarnpkg.com/downloads/0.16.1/yarn-v0.16.1.tar.gz
tar zvxf yarn-*.tar.gz
dist/bin/yarn install
@naganowl
naganowl / karma.conf.js
Created September 23, 2016 19:05
Make a single file with all tests for karma to consume
// Simplified config file
const path = require('path');
const junitOutput = process.env.CIRCLE_TEST_REPORTS || 'junit'
module.exports = function (config) {
config.set({
port: 9876,
logLevel: config.LOG_INFO,
@naganowl
naganowl / README.md
Created May 26, 2016 22:14
Precedence order of RSpec 2.99 tests
  • let is lazy, runs when it's invoked
  • let! are not lazy, runs immediately when the block is executed
  • before blocks are also not lazy, has same precedence as let!

For let! and before blocks, they execute based off source code order since it has the same precedence.

@naganowl
naganowl / README.md
Created April 27, 2016 16:15
Chaining method calls that are async with assignment can lead to problems

The first result will log undefined for the supposed deferred whereas the second will return the deferred. This is due to the resolution of the callback occurring before the assignment of the referenced variable happens. Note to reproduce this multiple times in console, a new variable will need to be used, otherwise it will seemingly pass because the deferred object already exists.

@naganowl
naganowl / README.md
Created September 16, 2015 04:08
Fork of react-router testing file in case it goes down (w/ some notes)
@naganowl
naganowl / Gruntfile.coffee
Created February 28, 2015 00:00
How Grunt task file rename works
# Taken from https://github.com/naganowl/chaplin-mocha-grunt/blob/master/Gruntfile.coffee
module.exports = (grunt) ->
'use strict'
# For use as rename method in copy:assets.
# Used to flatten the directory and place matched file in dest.
flattenFile = (dest, src) ->
if src.indexOf(@path) is 0
dest + src.slice @path.length
else
@naganowl
naganowl / Gruntfile.coffee
Created November 18, 2014 19:35
Using `livereload` with `grunt-contrib-watch`
module.exports = (grunt) ->
# Load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt)
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
# Only run tasks on modified files.
watch:
options:
@naganowl
naganowl / chaplinReuse.md
Created November 5, 2014 01:48
How to properly take advantage of the `reuse` method `Chaplin.Composer` provides `Chaplin.Controller`

Typically a controller is able to keep a view around (rather than disposing and creating anew) a view via this.reuse('name', Constructor, opts), where opts is an object.

However, if opts differs from the previous time reuse is called (as dictated by _.isEqual which is what Composition.check calls under the hood), then the invocation will cause the view to be disposed and created from scratch.

Thus, in order for it to be used properly, the View options hash should not contain dynamic information as it will cause the view to always be re-created. An example where this may come up is a paginated view where the query params could be passed in so that the view can update parts of the itself to reflect the updated query (such as the current page number, search query, etc.).

Obviously (or not), this dynamic information should be stored on the model/collection and can be done via overriding/enhancing the update call (such as fetch) via re-declaration with appropriate logic (like creating a property o

@naganowl
naganowl / README.md
Last active August 29, 2015 14:07
Adding LCOV generation to `grunt-mocha-blanket` to enhance `chaplin-mocha-grunt`