예제 #1
0
파일: spec.php 프로젝트: rstuven/pecs
 });
 it("should catch exceptions when invoking the function", function () {
     $exception = new Exception('failsauce');
     $spec = new pecs\Spec(null, function () use($exception) {
         throw $exception;
     });
     expect($spec->failures)->to_be_empty();
     expect(function () use($spec) {
         $spec->run();
     })->not_to_throw();
     expect($spec->failures)->to_have_count(1);
     expect($spec->failures[0])->to_be($exception);
 });
 it("should return a new expect object", function () {
     $spec = new pecs\Spec();
     $expect = $spec->expect('foo');
     expect($expect)->to_be_a('pecs\\Expect');
     expect($expect->actual)->to_be('foo');
     expect($expect->spec)->to_be($spec);
 });
 it('should pass if no assertion is expected', function () {
     $spec = new pecs\Spec(null, function ($s) {
         $s->expectAssertions()->to_be(0);
     });
     $spec->run($spec);
     expect($spec->passed())->to_be_true();
     expect($spec->failed())->to_be_false();
 });
 it('should pass if some assertions are expected', function () {
     $spec = new pecs\Spec(null, function ($s) {
         $s->expect(0)->to_be(0);