injecting mock module in angular using $provide.factory
<p>I'm trying to mock a child dependency of a service called <code>$localStorage</code></p>

<pre><code>  // inject modules
  beforeEach(function(){
    module('my.things');

    var _LocalStorage_ = function() {
      return {
        setItem: function(){
          return 'foo';
        }
      }
    };

    // mock the dependencies of the module we are testing
    module(function ($provide) {
      $provide.factory('$localStorage', _LocalStorage_);
    });
  });


  it.only('should add an object using $localStorage provider', function(){
    //here I get '$localStorage is undefined'
    var spySetItem = sinon.spy($localStorage, 'setItem');

    MyServices.addThing();

    expect(spySetItem.callCount).to.equal(1);
  })
</code></pre>

<p>I get an error '$localStorage is undefined'. How am I suppose to use this mocked dependency with a spy?</p>