Sha256: d31dc157d8ad1d478037a76a492776a5556c047d72ec065d96c9d5172ef8f15a

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

Ember.Test.registerHelper('httpRespond', function(app, verb, url, body, status) {
  if(typeof body !== 'string'){ body = JSON.stringify(body); }

  var found = fakehr.match(verb.toUpperCase(), url)

  if (found){
    Ember.run(function() {
      found.respond(status || 200, {'content-type': 'application/json'}, body);
    });
  } else {
    throw("No request intercepted for " + verb.toUpperCase() + " " + url + ". Intercepted requests were: " + fakehr.requests.map(function(r){ return r.method + " " + r.url}).join(", "));
  }
  return wait(app);
});

/*
  This is mildly crazy. Ember.Test increments requets on ajax start
  so promises won't resolve until all xhrs complete, but were mocking
  them all, so we just remove the ajaxStart and ajaxStop callbacks
  until we can merge into master and put some of this behind flags.
*/
Ember.Test.onInjectHelpers(function() {
  Ember.$(document).unbind("ajaxStart ajaxStop");
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ember-appkit-rails-0.5.0 vendor/assets/javascripts/httpRespond.js