Пример #1
0
 /**
  * Ran after an individual spec. May be used to display the results of that
  * particular spec.
  *
  * @param Spec $spec The spec after which to run this method
  */
 public function afterSpec(Spec $spec)
 {
     $leftPad = str_repeat(' ', self::TAB_SIZE * $this->depth);
     if ($spec->getResult() === Spec::FAILED) {
         $this->failedSpecs[] = $spec;
         $title = $this->formatter->red($spec->getTitle());
     } else {
         if ($spec->getResult() === Spec::INCOMPLETE) {
             $this->incompleteSpecs[] = $spec;
             $title = $this->formatter->cyan($spec->getTitle());
         } else {
             $title = $this->formatter->grey($spec->getTitle());
         }
     }
     $this->console->writeLn($leftPad . $title);
 }
Пример #2
0
 /**
  * Ran after an individual spec.
  *
  * @param Spec $spec The spec after which to run this method
  */
 public function afterSpec(Spec $spec)
 {
     $this->lineLength += 1;
     if ($spec->getResult() === Spec::FAILED) {
         $this->failedSpecs[] = $spec;
         $failure = $this->formatter->red('F');
         $this->console->write($failure);
     } else {
         if ($spec->getResult() === Spec::INCOMPLETE) {
             $this->incompleteSpecs[] = $spec;
             $incomplete = $this->formatter->cyan('I');
             $this->console->write($incomplete);
         } else {
             $this->console->write('.');
         }
     }
 }
Пример #3
0
 /**
  * Ran after an individual spec. May be used to display the results of that
  * particular spec.
  *
  * @param Spec $spec The spec after which to run this method
  */
 public function afterSpec(Spec $spec)
 {
     if ($spec->getResult() === Spec::FAILED) {
         $this->failedSpecs[] = $spec;
         $title = $this->formatter->red($spec);
     } else {
         if ($spec->getResult() === Spec::INCOMPLETE) {
             $this->incompleteSpecs[] = $spec;
             $title = $this->formatter->cyan($spec);
         } else {
             $title = $this->formatter->grey($spec);
         }
     }
     $this->console->writeLn($title);
 }
Пример #4
0
    context('getResult', function () use(&$suite) {
        it('returns PASSED if no exception was thrown', function () use(&$suite) {
            $closure = function () {
            };
            $spec = new Spec('spec', $closure, $suite);
            $spec->run();
            expect($spec->getResult())->toBe(Spec::PASSED);
        });
        it('returns FAILED if an exception was thrown', function () use(&$suite) {
            $closure = function () {
                throw new \Exception('exception');
            };
            $spec = new Spec('spec', $closure, $suite);
            $spec->run();
            expect($spec->getResult())->toBe(Spec::FAILED);
        });
        it('returns INCOMPLETE if no closure was ran', function () use(&$suite) {
            $spec = new Spec('spec', null, $suite);
            $spec->run();
            expect($spec->getResult())->toBe(Spec::INCOMPLETE);
        });
    });
    context('__toString', function () use(&$suite) {
        it('returns the suite title followed by the spec title', function () use(&$suite) {
            $closure = function () {
            };
            $spec = new Spec('SpecTitle', $closure, $suite);
            expect((string) $spec)->toEqual('TestSuite SpecTitle');
        });
    });
});
Пример #5
0
             throw new \Exception('exception');
         };
         $spec = new Spec('spec', $closure, $this->suite);
         $spec->run();
         expect($spec->getResult())->toBe(Spec::FAILED);
     });
     it('returns INCOMPLETE if no closure was ran', function () {
         $spec = new Spec('spec', null, $this->suite);
         $spec->run();
         expect($spec->getResult())->toBe(Spec::INCOMPLETE);
     });
     it('returns PENDING if marked as pending', function () {
         $spec = new Spec('spec', null, $this->suite);
         $spec->setPending();
         $spec->run();
         expect($spec->getResult())->toBe(Spec::PENDING);
     });
 });
 context('__toString', function () {
     it('returns the suite title followed by the spec title', function () {
         $closure = function () {
         };
         $spec = new Spec('SpecTitle', $closure, $this->suite);
         expect((string) $spec)->toEqual('TestSuite SpecTitle');
     });
 });
 describe('isPassed', function () {
     it('returns true when the spec passed', function () {
         $spec = new Spec('SpecTitle', function () {
         }, $this->suite);
         $spec->run();