matest 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/matest/capture_exception.rb +20 -11
- 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: 2448b223b54086b961d6c5b96130d1296ff55508
|
4
|
+
data.tar.gz: 10a0a8830bfacb9c6db403704f821534ba3e7a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ebda59e621cd3450c615a4b0c1ed141f562fd1181ce46c6315371f86dbda5085225a1e85efa9d65561a008570fc8923411604144d443107c89b3159b4f734c2
|
7
|
+
data.tar.gz: cd3213ab23b35c487b730fd127af012b707d5a85122a4a4df2e38f28747ea8cb7e0dc98311d4321d01eaac3b1c89e7cc06f6e48125265862e19c2e9675c37042
|
@@ -1,14 +1,23 @@
|
|
1
|
-
|
2
|
-
class
|
1
|
+
module Matest
|
2
|
+
class NoExceptionRaised < RuntimeError; end
|
3
|
+
class UnexpectedExceptionRaised < RuntimeError; end
|
3
4
|
|
4
|
-
def capture_exception(exception_class=
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
def capture_exception(exception_class=nil, &block)
|
6
|
+
expected_exception = exception_class || BasicObject
|
7
|
+
begin
|
8
|
+
block.call
|
9
|
+
if exception_class
|
10
|
+
raise Matest::NoExceptionRaised.new("Expected '#{exception_class.inspect}' from the block, but none was raised.")
|
11
|
+
else
|
12
|
+
raise Matest::NoExceptionRaised.new("Expected an Exception from the block, but none was raised.")
|
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
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
data/lib/matest/version.rb
CHANGED