//The tests
describe('<Unit Test>', function() {
  describe('Article:', function() {

    // var ArticleCtrl,
    //   $scope,
    //   $rootScope,
    //   $controller;

    beforeEach(module('arb'));

    beforeEach(inject(function($injector) {

      // _ArbRestMock_ = $injector.get('mock');      
      // $scope = $rootScope.$new();
      // $controller = $injector.get('$controller');


    }));

    describe('Method Save', function() {
      iit('test', 
        inject(function ($controller, _$httpBackend_, $rootScope, _ArbRest_, $state, conf) {

          $httpBackend = _$httpBackend_;
          var baseUrl = conf.getApiUrl();
          $httpBackend.expectPOST( baseUrl + '/article')
            .respond('[{"name":"tester"},{"name":"tester2"}]');
          ArbRest = _ArbRest_;
          $scope = $rootScope.$new();
          ArticleCtrl = $controller('ArticleCtrl', {
            $scope: $scope,
            ArbRest: ArbRest
          });

          $state.transitionTo('article.create');

          $scope.title = 'title of article';
          $scope.contents = 'contents of article';

          ArticleCtrl.create($state, $scope);
          console.log($httpBackend)

          $rootScope.$digest();
          $httpBackend.flush();
        })
      );

      it('should be able to save without problems', 
        inject(function(_$httpBackend_, $state, $controller, $rootScope) {
          var $httpBackend = _$httpBackend_;


          $scope = $rootScope.$new();

          ArticleCtrl = $controller('ArticleCtrl', {
            $scope: $scope,
          });

          $state.transitionTo('article.create');

          $scope.title = 'title of article';
          $scope.contents = 'contents of article';

          ArticleCtrl.create($state, $scope);
          console.log($httpBackend)

          $rootScope.$digest();
          $httpBackend.flush();

          //asset 
        })
      );

      it( 'should pass a dummy test ArticleCtrl', function() {
        ArticleCtrl.should.exist;
      });


      it('should be able to show an error when try to save without title', function(done) {
        article.title = '';

        return article.save(function(err) {
          should.exist(err);
          done();
        });
      });
    });

    // afterEach(function(done) {
    //   Article.remove({});
    //   User.remove({});
    //   done();
    // });
    // after(function(done){
    //   Article.remove().exec();
    //   User.remove().exec();
    //   done();
    // });
  });
});

@@ -87,86 +87,31 @@
     
-// var ArticleCtrl,%0A    //   $scope,%0A    //   $rootScope,%0A    //   $controller
+var $scope, ArticleCtrl
 ;%0A%0A 
@@ -175,85 +175,130 @@
 tion
+ 
 ($
-injector) %7B%0A%0A      // _ArbRestMock_ = $injector.get('mock');      
+controller, _$httpBackend_, $rootScope, $state, _ArbRest_, conf) %7B%0A%0A          var baseUrl = conf.getApiUrl();
 %0A      
-//
+   
  $sc
@@ -332,304 +332,129 @@
     
-// $controller = $injector.get('$controller');%0A%0A%0A    %7D));%0A%0A    describe('Method Save', function() %7B%0A      iit('test', %0A        inject(function ($controller, _$httpBackend_, $rootScope, _ArbRest_, $state, conf) %7B%0A%0A          $httpBackend = _$httpBackend_;%0A          var baseUrl = conf.getApiUrl(
+    ArticleCtrl = $controller('ArticleCtrl', %7B%0A            $scope: $scope,%0A            ArbRest: _ArbRest_%0A          %7D
 );%0A
+%0A
     
@@ -451,32 +451,33 @@
  %7D);%0A%0A          
+_
 $httpBackend.exp
@@ -472,16 +472,17 @@
 pBackend
+_
 .expectP
@@ -511,315 +511,334 @@
 le')
-%0A            .respond('%5B%7B%22name%22:%22tester%22%7D,%7B%22name%22:%22tester2%22%7D%5D');%0A          ArbRest = _ArbRest_;%0A          $scope = $rootScope.$new();%0A 
+.respond();%0A          %0A          $state.transitionTo('article.create');%0A%0A
     
-     ArticleCtrl = $controller('ArticleCtrl', %7B%0A            $scope: $scope,%0A            ArbRest: ArbRest%0A          %7D);%0A%0A          $state.transitionTo('article.create');
+%7D));%0A%0A    afterEach(inject(function ($rootScope, _$httpBackend_) %7B%0A%0A      $rootScope.$digest();%0A      _$httpBackend_.flush();%0A%0A    %7D));%0A%0A    describe('Method Save', function() %7B%0A      iit('test', %0A        inject(function ($rootScope, $state, conf) %7B
 %0A%0A  
@@ -982,108 +982,8 @@
 e);%0A
-          console.log($httpBackend)%0A%0A          $rootScope.$digest();%0A          $httpBackend.flush();
 %0A   

test fix ok