【发布时间】:2014-02-27 14:42:56
【问题描述】:
我目前正在编写一个将 Angular JS 集成到 Rails 应用程序中的教程。
测试设置如下:
describe( 'Club functionality', function() {
// mock Application to allow us to inject our own dependencies
beforeEach(angular.mock.module('league'));
// create the custom mocks on the root scope
beforeEach(angular.mock.inject(function($rootScope, _$httpBackend_, $state){
//create an empty scope
scope = $rootScope.$new();
// we're just declaring the httpBackend here, we're not setting up expectations or when's - they change on each test
scope.httpBackend = _$httpBackend_;
scope.$state = $state;
}));
afterEach(function() {
scope.httpBackend.verifyNoOutstandingExpectation();
scope.httpBackend.verifyNoOutstandingRequest();
});
...
完成本教程的该部分并浏览一些 Angular 文档后,我仍然不清楚为什么在包含 $httpBackend 依赖项时使用下划线。为什么会被嘲笑成这样? scope.httpBackend = _$httpBackend_;
【问题讨论】:
标签: angularjs testing karma-runner