@@ -1587,14 +1587,20 @@ window.jstestdriver && (function(window) {
1587
1587
} ) ( window ) ;
1588
1588
1589
1589
1590
- window . jasmine && ( function ( window ) {
1590
+ ( window . jasmine || window . mocha ) && ( function ( window ) {
1591
+
1592
+ var currentSpec = null ;
1593
+
1594
+ beforeEach ( function ( ) {
1595
+ currentSpec = this ;
1596
+ } ) ;
1591
1597
1592
1598
afterEach ( function ( ) {
1593
- var spec = getCurrentSpec ( ) ;
1594
- var injector = spec . $injector ;
1599
+ var injector = currentSpec . $injector ;
1595
1600
1596
- spec . $injector = null ;
1597
- spec . $modules = null ;
1601
+ currentSpec . $injector = null ;
1602
+ currentSpec . $modules = null ;
1603
+ currentSpec = null ;
1598
1604
1599
1605
if ( injector ) {
1600
1606
injector . get ( '$rootElement' ) . unbind ( ) ;
@@ -1616,13 +1622,8 @@ window.jasmine && (function(window) {
1616
1622
angular . callbacks . counter = 0 ;
1617
1623
} ) ;
1618
1624
1619
- function getCurrentSpec ( ) {
1620
- return jasmine . getEnv ( ) . currentSpec ;
1621
- }
1622
-
1623
1625
function isSpecRunning ( ) {
1624
- var spec = getCurrentSpec ( ) ;
1625
- return spec && spec . queue . running ;
1626
+ return currentSpec && currentSpec . queue . running ;
1626
1627
}
1627
1628
1628
1629
/**
@@ -1647,11 +1648,10 @@ window.jasmine && (function(window) {
1647
1648
return isSpecRunning ( ) ? workFn ( ) : workFn ;
1648
1649
/////////////////////
1649
1650
function workFn ( ) {
1650
- var spec = getCurrentSpec ( ) ;
1651
- if ( spec . $injector ) {
1651
+ if ( currentSpec . $injector ) {
1652
1652
throw Error ( 'Injector already created, can not register a module!' ) ;
1653
1653
} else {
1654
- var modules = spec . $modules || ( spec . $modules = [ ] ) ;
1654
+ var modules = currentSpec . $modules || ( currentSpec . $modules = [ ] ) ;
1655
1655
angular . forEach ( moduleFns , function ( module ) {
1656
1656
modules . push ( module ) ;
1657
1657
} ) ;
@@ -1718,13 +1718,13 @@ window.jasmine && (function(window) {
1718
1718
return isSpecRunning ( ) ? workFn ( ) : workFn ;
1719
1719
/////////////////////
1720
1720
function workFn ( ) {
1721
- var spec = getCurrentSpec ( ) ;
1722
- var modules = spec . $modules || [ ] ;
1721
+ var modules = currentSpec . $modules || [ ] ;
1722
+
1723
1723
modules . unshift ( 'ngMock' ) ;
1724
1724
modules . unshift ( 'ng' ) ;
1725
- var injector = spec . $injector ;
1725
+ var injector = currentSpec . $injector ;
1726
1726
if ( ! injector ) {
1727
- injector = spec . $injector = angular . injector ( modules ) ;
1727
+ injector = currentSpec . $injector = angular . injector ( modules ) ;
1728
1728
}
1729
1729
for ( var i = 0 , ii = blockFns . length ; i < ii ; i ++ ) {
1730
1730
try {
0 commit comments