Skip to content

Instantly share code, notes, and snippets.

@kurko
kurko / _README.md
Last active January 1, 2016 04:38
Ember.js - Writing contract tests for your Ember Data models

Ember.js Testing package was a great addition to the project. It allowed us to have fast specs to guarantee the defined behavior. However, there's no convention on how you should guarantee that your models, the heart of any Ember.js application, are valid in relation to your backend.

Put another way, if you have an User model with a name attribute, how can you be sure that your backend is still responding with {"user": {"name": "Your Name"}}? So, even though your acceptance specs pass, you're stubbing out your models with FIXTURES.

Most people either manually test their apps or create an end-to-end test with the backend server, which is slow as hell (think of Capybara). The good news is that there are conventions for solving this since like forever. One way to guarantee this integrity is via Contract tests (http://martinfowler.com/bliki/IntegrationContractTest.html). Basically, you have a test to guarantee your models are matching your backend.

Using server-side end-to-end tests have many drawbacks,

@mixonic
mixonic / vcr_proxy.js
Last active January 1, 2016 00:59
Ember.js VCRProxy
// Record changes to an ObjectProxy and allow them to be stepped through
// or jumped to.
//
// For an example, see http://emberjs.jsbin.com/EJEcoxO/12/edit?html,js,output
//
// There is a bower/npm installable version of this library on GitHub:
// https://github.com/mixonic/ember-vcr-proxy
//
(function (global) {
@rwjblue
rwjblue / computed_on_pojos.js
Created December 13, 2013 15:24
Using Ember.computed on a Plain Old Javascript Object.
pojo = {awesome: false};
Ember.defineProperty(pojo, 'computedAwesomeness', Ember.computed.not('awesome'));
alert("Computed Awesomeness: " + Ember.get(pojo, 'computedAwesomeness'));
@coderberry
coderberry / chrome-cheat-sheet.md
Last active March 10, 2023 13:56
Chrome Canary Console Cheat Sheet
@machty
machty / router-js-refactor-architecture.md
Last active July 31, 2019 18:39
Overview of the architecture and approach to the router.js refactor

router.js Architecture

Let this serve as a guide for anyone who'd like to dig into router.js's internals, understand what's going on, and hopefully contribute!

Scope of router.js (et al)

router.js is most popularly known as the routing microlib used by the Ember.js Router, though other folk have been known to use it beyond Ember, including some Angular folk who weren't satisfied with

App.Store = DS.Store.extend
pushRecord: (type, record) ->
key = type.underscore().pluralize()
payload = {}
payload[key] = [record]
@pushPayload type, payload
@getById type, record.id
@chexton
chexton / button.html
Last active December 18, 2015 07:19
button.html
<!--Start button-->
<table cellspacing="0" border="0" cellpadding="8" width="240">
<tr>
<td height="35" bgcolor="#33CC33" style="border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; font-size: 16px; font-family: sans-serif; color: #333333; margin: 0; padding: 0; text-align: center;" class='vero-editable'>
<a href="http://getvero.com" style="font-weight:bold; text-decoration:underline;color: #ffffff;text-decoration:none;">Check out your cart &rarr;</a>
</td>
</tr>
</table>
<!-- End button-->
@machty
machty / router-facelift-guide.md
Last active July 10, 2024 15:14
Guide to the Router Facelift

Ember Router Async Facelift

The Ember router is getting number of enhancements that will greatly enhance its power, reliability, predictability, and ability to handle asynchronous loading logic (so many abilities), particularly when used in conjunction with promises, though the API is friendly enough that a deep understanding of promises is not required for the simpler use cases.

@lukemelia
lukemelia / buffered_proxy.js
Last active May 5, 2016 20:47
Buffered Proxy, extracted from Yapp codebase
var empty, get, set,
__hasProp = {}.hasOwnProperty;
get = Ember.get;
set = Ember.set;
empty = function(obj) {
var key;
for (key in obj) {
if (!__hasProp.call(obj, key)) continue;
@ndbroadbent
ndbroadbent / json_munging_patch.rb
Created February 12, 2013 00:24
Save this to config/initializers/json_munging_patch.rb until https://github.com/rails/rails/pull/8862 or an alternative fix is merged.
# Patch from https://github.com/rails/rails/pull/8862
module ActionDispatch
Request.class_eval do
# Remove nils from the params hash
def deep_munge(hash)
hash.each do |k, v|
case v
when Array