title: Asserting a specific stub call was made with the required arguments using sinon
body: <p>Let's say you are testing a function that will call a dependency multiple times with different arguments:</p>
  
  <pre><code>var sut = {
      ImportantFunction: function(dependency){
          dependency("a", 1);
          dependency("b", 2);
      }
  };
  </code></pre>
  
  <p>Using QUnit + Sinon <strong>and assuming the order of the calls is not important</strong>, I could write the following test that makes sure the function calls the dependency as expected:</p>
  
  <pre><code>test("dependency was called as expected", function () {
      var dependencyStub = sinon.stub();
  
      sut.ImportantFunction(dependencyStub);
  
      ok(dependencyStub.calledTwice, "dependency was called twice");            
      sinon.assert.calledWith(dependencyStub, "a", 1);
      sinon.assert.calledWith(dependencyStub, "b", 2);
  });
  </code></pre>
  
  <p><strong>But what if the order is important and I want the test to take it into account?</strong> What is the best way to write such a test using QUnit+Sinon?</p>
  
  <p>I have used the following approach, but I am losing the descriptive failure message provided by <a href="http://sinonjs.org/docs/#assertions" rel="nofollow">sinon assertions</a> (which shows expected and actual values). For this I have just manually added some descriptive message, but it is not as useful as having a failure message with the expected and actual values (and has to be manually maintained).</p>
  
  <pre><code>ok(dependencyStub.firstCall.calledWith("a", 1), "dependency called with expected args 'a', 1");
  ok(dependencyStub.secondCall.calledWith("b", 2), "dependency called with expected args 'b', 2");
  </code></pre>
  
  <p>Is there a way of using an assertion like <code>sinon.assert.calledWith</code> for a particular call like the first or second call?</p>
  
  <p>Sample setup in <a href="http://jsfiddle.net/bu0u1exs/" rel="nofollow">this fiddle</a></p>