matest 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/matest/capture_exception.rb +16 -16
- data/lib/matest/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c614bca6c6b527d39890dc37557059b3bac997fe
|
4
|
+
data.tar.gz: bc099b1483b4d64002300fc92056283ddaede281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21fe688fa7c433566315b57523ad5d7982fb6debfd090ff7002ee4e1dbc1410c5bc216cae4fb8166a6197ece6599179facb542676eaae9b6e899c00f739bf012
|
7
|
+
data.tar.gz: ae46828ff6fc07333aada9131ac8e0e1af8680b5f624a0d3c95049f82c8e5e684bce7365d72ecee20a168392f9138516ad35e91a5d0e08b3cf3329ab4fa0dd8e
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module Matest
|
2
2
|
class NoExceptionRaised < RuntimeError; end
|
3
3
|
class UnexpectedExceptionRaised < RuntimeError; end
|
4
|
+
end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
false
|
15
|
-
rescue Matest::NoExceptionRaised => e
|
16
|
-
raise e
|
17
|
-
rescue expected_exception => e
|
18
|
-
e
|
19
|
-
rescue BasicObject => e
|
20
|
-
raise e
|
6
|
+
def capture_exception(exception_class=nil, &block)
|
7
|
+
expected_exception = exception_class || BasicObject
|
8
|
+
begin
|
9
|
+
block.call
|
10
|
+
if exception_class
|
11
|
+
raise Matest::NoExceptionRaised.new("Expected '#{exception_class.inspect}' from the block, but none was raised.")
|
12
|
+
else
|
13
|
+
raise Matest::NoExceptionRaised.new("Expected an Exception from the block, but none was raised.")
|
21
14
|
end
|
15
|
+
false
|
16
|
+
rescue Matest::NoExceptionRaised => e
|
17
|
+
raise e
|
18
|
+
rescue expected_exception => e
|
19
|
+
e
|
20
|
+
rescue BasicObject => e
|
21
|
+
raise e
|
22
22
|
end
|
23
23
|
end
|
data/lib/matest/version.rb
CHANGED