Testing HttpInterceptor

HTML

<script src="http://code.angularjs.org/1.0.0/angular-1.0.0.js"></script>
<script src="https://raw.github.com/pivotal/jasmine/master/lib/jasmine-core/jasmine.js"></script>
<script src="https://raw.github.com/pivotal/jasmine/master/lib/jasmine-core/jasmine-html.js"></script>
<script src="http://code.angularjs.org/1.0.0/angular-mocks-1.0.0.js"></script>
<script src="http://code.angularjs.org/1.0.0/angular-resource-1.0.0.js"></script>

CSS

body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }

#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
#TrivialReporter .runner.running { background-color: yellow; }
#TrivialReporter .options { text-align: right; font-size: .8em; }
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
#TrivialReporter .suite .suite { margin: 5px; }
#TrivialReporter .suite.passed { background-color: #dfd; }
#TrivialReporter .suite.failed { background-color: #fdd; }
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
#TrivialReporter .spec.skipped { background-color: #bbb; }
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
#TrivialReporter .passed { background-color: #cfc; display: none; }
#TrivialReporter .failed { background-color: #fbb; }
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
#TrivialReporter .resultMessage span.result { display:...

JavaScript

/********** APP **********/  
var myApp = angular.module('myApp', ['myService'], function(){})
    .config(function ($httpProvider) {
        $httpProvider.responseInterceptors.push('httpInterceptor');
     });


myApp.factory('httpInterceptor', function ($q) {
    
    function success(response) {
         return response;
    }
    
    function error(response) {
        var status = response.status;

        if(status == 500) {
            alert('Big time error');
            var deffered = $q.defer();
            return deffered.promise;
        }
        
        return $q.reject(response);
    }    
    
    return function (promise) {
        return promise.then(success, error)
    }

});


/********** CONTROLLER **********/  
function AppCtrl($scope, SuccessService, ErrorService) {
    
    $scope.successStatus = 'unknown';
    $scope.triggerSuccess = function() {
        SuccessService.get( {},
            function success(rsp){
                $scope.successStatus = 'success';
            },
            function error(rsp){
                $scope.successStatus = 'error';
            })
    };        
    
    $scope.errorsStatus = 'unknown';
    $scope.triggerError = function() {
        ErrorService.get( {},
            function success(rsp){
                $scope.errorsStatus = 'success';
            },
            function error(rsp){
                $scope.errorsStatus = 'error';
            })
    };
}

        

/********** SERVICES **********/        
angular.module('myServices', ['ngResource'])

    .factory('SuccessService', function($resource) {
        return $resource('/me-a-200-success');
    })

    .factory('ErrorService', function($resource) {
        return $resource('/thow-me-a-500-please');
    })

        
        
/********** TESTS **********/  
describe('App Controller Tests', function() {
    var scope, appCtrl, $resource, $rootScope,  $httpBackend; 

    beforeEach(module('myApp'));
    beforeEach(module('myServices'));
   ...