title: Mocking out AJAX calls with Dojo XHR
body: <p>I'm attempting to mock the response of a dojo xhr request, but I haven't found a good solution.</p>
  
  <p>Ideally, I'd like to see a solution similar to the jQuery <a href="http://enterprisejquery.com/2010/07/mock-your-ajax-requests-with-mockjax-for-rapid-development/" rel="nofollow">mockjax plugin</a> where I can set a specific call based on a url, e.g.:</p>
  
  <pre><code> $.mockjax({
    url: '/restful/fortune',
    responseTime: 750,
    responseText: {
      status: 'success',
      fortune: 'Are you a turtle?'
    }
   });
  </code></pre>
  
  <p>My initial thought was to utilize the "/dojo/io/send" channel, but I haven't been able to get a modified response to be loaded after modifying the dojo Deferred object.</p>
  
  <p>The other thought is to use a pass-through method that would determine if an actual xhr request should be made, e.g.:</p>
  
  <pre><code>function xhrRequest(xhrArgs) {
     if(shouldMock) {
        var fakeReturnJson = dojo.toJson({
          howdy: "that's odd!",
          isStrange: false
        }); 
        return fakeReturnJson;
     } else {
        dojo.xhr(xhrArgs);
     }
  
  }
  </code></pre>
  
  <p>Can someone tell me the best way to go about mocking dojo xhr calls?</p>
  
  <p>Thanks!</p>