@@ -16,7 +16,7 @@ public function testSpecification()
1616 $ this ->user ->name = 'jon ' ;
1717 $ this ->assertEquals ('jon ' , $ this ->user ->name );
1818 });
19-
19+
2020 $ this ->assertEquals ('davert ' , $ this ->user ->name );
2121
2222 $ this ->specify ('i can fail here but test goes on ' , function () {
@@ -57,7 +57,7 @@ function testAfterCallback()
5757 $ this ->user = "jon " ;
5858 });
5959 $ this ->assertEquals ('davert ' , $ this ->user );
60- }
60+ }
6161
6262 function testMultiAfterCallback ()
6363 {
@@ -104,6 +104,29 @@ public function testExceptions()
104104 }, ['throws ' => 'fail ' ]);
105105 }
106106
107+ public function testExceptionsWithMessages ()
108+ {
109+ $ this ->specify ('user is invalid ' , function () {
110+ throw new Exception ("test message " );
111+ }, ['throws ' => ['Exception ' , 'test message ' ]]);
112+
113+ $ this ->specify ('user is invalid ' , function () {
114+ throw new RuntimeException ("test message " );
115+ }, ['throws ' => ['RuntimeException ' , 'test message ' ]]);
116+
117+ $ this ->specify ('user is invalid ' , function () {
118+ throw new RuntimeException ("test message " );
119+ }, ['throws ' => [new RuntimeException (), "test message " ]]);
120+
121+ $ this ->specify ('i can handle fails ' , function () {
122+ $ this ->fail ("test message " );
123+ }, ['throws ' => ['fail ' , 'test message ' ]]);
124+
125+ $ this ->specify ('ignores an empty message ' , function () {
126+ $ this ->fail ("test message " );
127+ }, ['throws ' => ['fail ' ]]);
128+ }
129+
107130 /**
108131 * @expectedException RuntimeException
109132 */
@@ -140,7 +163,7 @@ public function testDeepCopy()
140163 $ this ->assertEquals (2 , $ this ->a ->prop ->prop );
141164 });
142165 $ this ->assertEquals (1 , $ this ->a ->prop ->prop );
143-
166+
144167 }
145168
146169 public function testConfiguration ()
0 commit comments