testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
377 stars 154 forks source link

$templateCache not being hit #205

Closed rrrkren closed 7 years ago

rrrkren commented 7 years ago

I'm using the following code to test my directive (with external template):

app.directive('test-element',function(){
    return {
        templateUrl: '/statics/template.html'
        restrict: 'E'
    }
});

//test
var $compile,scope;
beforeEach(function(){
    module('app');
    inject(function(_$compile_,_$rootScope_,$templateCache){
        $compile = _$compile_;
        scope = _$rootScope.$new();
        $templateCache.put("/statics/template.html","<h1>test</h1>");
    }));

it ('works',function(){
    var element = $compile('<test-element></test-element>')(scope)
    scope.$digest();
    console.log(element);
    pending();
}

The element is not being compiled, and shown as <test-element class='ng-scope'></test-element>.

I've put a console.log on angular's templateCache source code, and it seems that the put is run properly but get is never used.

Can anyone point me to a correct direction? Thanks!

rrrkren commented 7 years ago

it turned out to be a custom httpInterceptor that screwed this up.