title: jasmine: How can i declare a loop of 'its' instead of a loop of 'expects' for testing an angular factory?
body: <p>This is the angular factory i want to test:</p>
  
  <pre><code>var myApp = angular.module('myApp', []);
  
  myApp.factory('factoryTest',function(){
      return [
          {number: 1, name: 'one'},
          {number: 2, name: 'two'},
          {number: 3, name: 'three'}
      ];
  });
  </code></pre>
  
  <p>And this is the jasmine way of testing it:</p>
  
  <pre><code>beforeEach(inject(function (_factoryTest_) {
      factoryTest = _factoryTest_;
  }));
  
  it('verifies every item has a number', function(){
      for(var i=0;i &lt; factoryTest.length; i++){
          expect(factoryTest[i].number).toEqual(jasmine.any(Number));
      }
  });
  </code></pre>
  
  <p>the above test works however in case of failure you don't know which item is the failing one. </p>
  
  <p>To make the error meaningful it'd have to be refactored into a loop of 'its':</p>
  
  <pre><code>beforeEach(inject(function (_factoryTest_) {
      factoryTest = _factoryTest_;
  }));
  
  for(var i=0;i &lt; factoryTest.length; i++){
      it('verifies ' + factoryTest[i].name + ' has a number', function(){
          expect(factoryTest[i].number).toEqual(jasmine.any(Number));
      });
  }
  </code></pre>
  
  <p>However, this fails because the factoryTest isn't injected in the describe context. How can i inject the angular factory to make it work?</p>
  
  <p>I've done a fiddle: <a href="http://jsfiddle.net/rodhom/woq9fhg9/" rel="nofollow">http://jsfiddle.net/rodhom/woq9fhg9/</a></p>
  
  <p>I first found the idea of looping 'its', here: <a href="http://tosbourn.com/using-loops-in-jasmine/" rel="nofollow">http://tosbourn.com/using-loops-in-jasmine/</a></p>