title: How to correctly use the mock-ajax library with Jasmine
body: <p>I have a function which calls out for JSON and then in the success function makes some changes to the DOM. I'm trying to use the <a href="https://github.com/pivotal/jasmine-ajax" rel="nofollow">mock-ajax library</a> in my Jasmine tests to avoid having to expose the various private  functions for mocking.</p>
  
  <p>Even though when stepping through the test the <code>request.response</code> is set the onSuccess method is never called.</p>
  
  <p>My tests:</p>
  
  <pre><code> describe('the table loader', function () {
          var request;
  
          beforeEach(function() {
              //html with a loader div, an output div and a transit and dwell template
              setFixtures('&lt;div class="loader"&gt;&lt;/div&gt;&lt;div class="row"&gt;&lt;div id="output" class="col-xs-12"&gt;&lt;/div&gt;&lt;/div&gt;&lt;script id="thingTemplate" type="text/x-handlebars"&gt;{{snip}}&lt;/script&gt;');
              expect($('.loader')).toBeVisible();
  
              //start ajax call
              window.dashboards.thing.display({
                  loaderId: '.loader',
                  templateId: '#thingTemplate',
                  templateOutletId: '#output',
                  dataUrl: '/my/fake/url'
              });
              //catch the ajax request
              request = mostRecentAjaxRequest();
          });
  
          describe('on success', function () {
              beforeEach(function() {
                  //populate the response
                  request.response({
                      status: 200,
                      responseText: "{rowItem: [{},{},{}]}"
                  });
              });
  
              it('should hide the loader', function () {
                  //thing should now receive that JSON and act accordingly
                  expect($('.loader')).not.toBeVisible();
              });
          });
      });
  </code></pre>
  
  <p>and my code:</p>
  
  <pre><code>(function (dashboards, $) {
      dashboards.thing = dashboards.thing || {};
  
      var compileTable = function(templateId, jsonContext) {
          var source = $(templateId).html();
          var template = Handlebars.compile(source);
          var context = jsonContext;
          return template(context);
      };
  
      var getDashboardData = function(options) {
          $.getJSON(
              options.dataUrl,
              function (data) {
                  processDashboardData(options, data);
              }
          ).fail(function (jqxhr, textStatus, error) {
              console.log('error downloading dashboard data');
              console.log(textStatus + ': ' + error);
          }).always(function() {
              console.log('complete');
          });
      };
  
      var processDashboardData = function (options, data) {
          $(options.loaderId).hide();
          $(options.templateOutletId).html(compileTable(options.templateId, data));
      };
  
      dashboards.thing.display = function (options) {
          getDashboardData(options);
      };
  }(
      window.dashboards = window.dashboards || {},
      jQuery
  ));
  </code></pre>
  
  <p>None of the deferred functions (success, error, and always) are being called.</p>
  
  <h2>Edit</h2>
  
  <p>based on @gregg's answer below (and he's right I didn't include the UseMock call in the example code) this feels like a versions issue. As even with that call included this still isn't working for me.</p>
  
  <p>I've added a <a href="https://github.com/pauldambra/JasmineMockAjax-StackOverflow/" rel="nofollow">runnable example on github</a></p>