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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a20475ba5064a302ebc0c15c66b89d1397aca7cd
4
- data.tar.gz: 44348821c95ddb0fc69359db9bcac993f31e1eb9
3
+ metadata.gz: 2448b223b54086b961d6c5b96130d1296ff55508
4
+ data.tar.gz: 10a0a8830bfacb9c6db403704f821534ba3e7a1d
5
5
  SHA512:
6
- metadata.gz: b3280a9e1c7067cfbf03ffa82ca7c7eabe51e7b5c348e399320564d60beb3686bafb0bc39f61ea983b8f6ffd33d615dea0adbafd78daaf4234c1d864c28bdfc7
7
- data.tar.gz: ab3739128bdf8f4a53741af7c6d3e1b8ac1749b005996e424b3535e42c6108d8ec9c956661199d8c7e251620fe148362fa5fd777fa2343e195a3aaec6dfbff66
6
+ metadata.gz: 1ebda59e621cd3450c615a4b0c1ed141f562fd1181ce46c6315371f86dbda5085225a1e85efa9d65561a008570fc8923411604144d443107c89b3159b4f734c2
7
+ data.tar.gz: cd3213ab23b35c487b730fd127af012b707d5a85122a4a4df2e38f28747ea8cb7e0dc98311d4321d01eaac3b1c89e7cc06f6e48125265862e19c2e9675c37042
@@ -1,14 +1,23 @@
1
- class NoExceptionRaised < RuntimeError; end
2
- class UnexpectedExceptionRaised < RuntimeError; end
1
+ module Matest
2
+ class NoExceptionRaised < RuntimeError; end
3
+ class UnexpectedExceptionRaised < RuntimeError; end
3
4
 
4
- def capture_exception(exception_class=BasicObject, &block)
5
- begin
6
- block.call
7
- raise NoExceptionRaised.new
8
- false
9
- rescue exception_class => e
10
- e
11
- rescue BasicObject => e
12
- raise UnexpectedExceptionRaised.new
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
@@ -1,3 +1,3 @@
1
1
  module Matest
2
- VERSION = "1.5.3"
2
+ VERSION = "1.5.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti