I've been working on a unit test with angular.mock.$httpBackend for an angular service that uses $http. I'm running into some issues related to injecting all the dependencies, because my test case needs to access the service, which in turn needs to access $httpBackend.
However, the specific issue that is tripping me up now is that sometimes the angular.mock.inject() convenience method executes the function it wraps immediately, and sometimes it just returns a copy of the function. I see in the source that this is based on a property called currentSpec.isRunning. What does this mean? Is this a Testacular or Jasmine property? I haven't gone that far down the rabbit hole yet...
Last I checked, the return value of angular.mock.inject() was based upon what type of Jasmine context you are in (I'm assuming they changed it up a bit in 1.2 with the addition of mocha support).
Essentially, if your in a spec (actually inside of a callback passed to beforeEach):
beforeEach(function () {
inject(function () { });
});
Then it will execute the injection immediately; however, if you are still defining the spec:
beforeEach(inject(function () { }));
Then it will return a function. Otherwise it would execute before your tests were to run, and not be terribly useful. This seems to just be provided as a slightly more convenient/less verbose syntax.