title: Sinonjs fakeserver - multiple ajax calls
body: <p>I use QUnit together with sinon. How can I make sinon's <a href="http://sinonjs.org/docs/#server" rel="nofollow">fakeserver</a> respond to chained ajax called made from the same method?</p>
  
  <pre><code>module('demo', {
      beforeEach: function(){
          this.server = sinon.fakeServer.create();
      },
      afterEach: function(){
          this.server.restore();
      }
  });
  
  test('chained ajax calls', function(assert){
  
      this.server.respondWith('GET', '/foo', [200, 
      { 'Content-Type': 'application/json' }, '{ "foo": 1 }' ]);
  
      this.server.respondWith('GET', '/bar', [200, 
      { 'Content-Type': 'application/json' }, '{ "bar": 1 }' ]);
  
      var successCount = 0;
  
      $.get('/foo', function(data){
          successCount++;
          $.get('/bar', function(){
              console.log('bar success');
              successCount++;
          });
      });
  
      this.server.respond();
      assert.strictEqual(successCount, 2);
  });
  </code></pre>
  
  <p>My issue above is that I only get the response from one of the methods. Is the fakeserver able to handle this?</p>
  
  <p><strong>Update:</strong> It seems like adding another <code>server.respond()</code> solves the problem. But there must be a better way, right?</p>
  
  <p>According to the docs, it sounds like one call should to the job, regardless of ajax call count:</p>
  
  <blockquote>
    <p>server.respond();
    Causes all queued asynchronous requests to receive a response.</p>
  </blockquote>
  
  <p>Fiddle: <a href="http://jsfiddle.net/3qj20r5m/1/" rel="nofollow">http://jsfiddle.net/3qj20r5m/1/</a></p>