Skip to content

Instantly share code, notes, and snippets.

When testing Ember code, without putting expectations in a Ember.run callback, you'll get this error:

Failure/Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run

The error recommends wrapping expectations in Ember.run:

describe 'something', ->
@biscuitvile
biscuitvile / README.md
Created September 21, 2013 14:24
Alternative interactions for Ember integration testing (avoid drag and drop)

These 5 assertions run in 365 millliseconds under qunit-rails using an alterative interaction for testing that avoids the drag and drop features in our app. One high level Cucumber scenario using Capybara to ensure drag and drop is working correctly can be combined with numerous Qunit intgration tests of a much more specific assertion level to guarantee application functionality in a faster-feedback interaction for better developer TDD. Conditional logic in the view can be slimmed down with partials or custom Handlebars helpers. Libraries like Syn.js and jquery.simulate do exist to test drag and drop, but it is my current opnion that it is simply much easier to test drag and drop with Capybara in a headless browser than it is to inside an iframe under qunit-rails or Konacha.

# Code:
$ -> # a.k.a. jQuery.ready ->
$("#hash-value-when-page-loaded").text(location.hash)
# Test:
location.hash = "foo"
fakeDomReady()
sinon.Container = function(namespace) {
this.namespace = namespace;
this._cache = [];
this._mocks = [];
this.container = namespace.__container__;
};
var mock = function(context, method, args) {
var object = context[method].apply(context, args);
return mockObject(context, object);
<!-- Mocha test output goes here. -->
<div id="mocha"></div>
<!-- Handlebars templates for our application. -->
<script type="text/x-handlebars">
<h1>Testing Ember.js with Mocha</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
@biscuitvile
biscuitvile / _form.handlebars
Created August 14, 2013 02:19
Radio button implementation in Ember.js The checked radio button currently does not change is value appropriately when the switching from model to model. Gender is assumed to be a binary choice in cats for the purposes of a breakable toy.
<p>
<label>
{{ view CatWorld.RadioButton name="genderSelection"
contentBinding="controller.gender" selectionBinding="gender" value="Male" id="Male" }}
Male
<label>
<label>
{{ view CatWorld.RadioButton name="genderSelection"
@biscuitvile
biscuitvile / gist:6142454
Created August 2, 2013 19:01
When capybara just won't wait with have_css, find, etc
until page.evaluate_script("$('section#receipt').length === 1;") == true do
sleep (0.1)
end
sinon.Container = function(namespace) {
this.namespace = namespace;
this._cache = [];
this._mocks = [];
this.container = namespace.__container__;
};
var mock = function(context, method, args) {
var object = context[method].apply(context, args);
return mockObject(context, object);
@biscuitvile
biscuitvile / pair-along-faq.md
Last active December 13, 2015 21:48
RubyJax Pair-Along 3/2/13 FAQ

RubyJax Pair-Along FAQ

Friday, March 1st, 2013

6:30 PM - 8:30 PM

Saturday, March 2nd, 2013

9:00 AM - 5:00 PM