Exception: RaiseAssay
- Inherits:
-
RescueAssay
- Object
- Exception
- Assertion
- RescueAssay
- RaiseAssay
- Defined in:
- lib/assay/raise_assay.rb
Constant Summary
Constants inherited from Assertion
Constants included from Assay::Assertable
Class Method Summary collapse
- .assert_message(*exceptions) ⇒ Object
-
.fail?(*exceptions) ⇒ Boolean
Check negated assertion.
-
.pass?(*exceptions) ⇒ Boolean
Check assertion.
- .refute_message(*exceptions) ⇒ Object
Methods inherited from Assertion
by_name, by_operator, inherited, register, subclasses
Methods included from Assay::Assertable
#[], #assert!, #assert_message, #assertive_name, #assertor, #fail?, #operator, #pass?, #refute!, #refute_message
Class Method Details
.assert_message(*exceptions) ⇒ Object
44 45 46 47 |
# File 'lib/assay/raise_assay.rb', line 44 def self.(*exceptions) exp = exceptions.map{ |e| e.inspect }.join(' or ') "raise #{exp}" #, but was #{err} instead." end |
.fail?(*exceptions) ⇒ Boolean
Check negated assertion.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/assay/raise_assay.rb', line 26 def self.fail?(*exceptions) exceptions = [RuntimeError] if exceptions.empty? begin yield true rescue Exception => e !exceptions.any? do |x| x.instance_of?(Module) ? x === e : e.class == x end end end |
.pass?(*exceptions) ⇒ Boolean
Check assertion.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/assay/raise_assay.rb', line 11 def self.pass?(*exceptions) exceptions = [RuntimeError] if exceptions.empty? begin yield false rescue Exception => e exceptions.any? do |x| x.instance_of?(Module) ? x === e : e.class == x end end end |
.refute_message(*exceptions) ⇒ Object
52 53 54 55 |
# File 'lib/assay/raise_assay.rb', line 52 def self.(*exceptions) exp = exceptions.map{ |e| e.inspect }.join(' or ') "! raise #{exp}" #, but was #{err} instead." end |