angular/protractor — pull request #521 by alexanderjeurissen (2014-02-13 17:16:04+00:00)
Title: feat(protractor): add addMockModules method to protractor.

The addMockModules method allows us to avoid having multiple
browser.addMockModule statements incase we chain mockModules from
several pageObjects.

currently chaining multiple mockModules from several page objects isn't really DRY.

```javascript
function pageObjectOne () {
this.httpBackendMock = function () {
angular.module('httpBackendMock', ['ngMockE2E', 'nameOfYourAngularApp'])
.run(function ($httpBackend) {
//http backend mocks here
});
};
};

function pageObjectTwo () {
this.anotherHttpBackendMock = function () {
angular.module('anotherHttpBackendMock', ['ngMockE2E', 'nameOfYourAngularApp'])
.run(function ($httpBackend) {
//http backend mocks here
});
};
};

var pageOne = new pageObjectOne();
var pageTwo = new pageObjectTwo();

beforeEach(function(){
browser.addMockModule('httpBackendMock', pageOne.httpBackendMock);
browser.addMockModule('anotherHttpBackendMock', pageTwo.anotherHttpBackendMock);
});
```

If this feature is implemented the above code can be refactored to:

```javascript
function pageObjectOne () {
this.httpBackendMock = function () {
angular.module('httpBackendMock', ['ngMockE2E', 'nameOfYourAngularApp'])
.run(function ($httpBackend) {
//http backend mocks here
});
};
};

function pageObjectTwo () {
this.anotherHttpBackendMock = function () {
angular.module('anotherHttpBackendMock', ['ngMockE2E', 'nameOfYourAngularApp'])
.run(function ($httpBackend) {
//http backend mocks here
});
};
};

var pageOne = new pageObjectOne();
var pageTwo = new pageObjectTwo();

beforeEach(function () {
browser.addMockModules([{
name: 'httpBackendMock',
script: pageOne.httpBackendMock
}, {
name: 'anotherHttpBackendMock',
script: pageTwo.anotherHttpBackendMock
}]);
});
```