Exception: ReturnAssay
- Inherits:
-
ExecutionAssay
- Object
- Exception
- Assertion
- ExecutionAssay
- ReturnAssay
- Defined in:
- lib/assay/return_assay.rb
Overview
Assert that a block of code returns a specific result, also fails if an error is raised in the block.
Constant Summary
Constants inherited from Assertion
Constants included from Assay::Assertable
Class Method Summary collapse
-
.fail?(returns, *arguments) ⇒ Boolean
Check that a block does NOT return a specific value comparing the
returns
argument and actual returned value with the ‘#==` operator. -
.pass?(returns, *arguments) ⇒ Boolean
Check that a block returns a specific value comparing the
returns
argument and actual returned value with the ‘#==` operator.
Methods inherited from ExecutionAssay
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
.fail?(returns, *arguments) ⇒ Boolean
Check that a block does NOT return a specific value comparing the returns
argument and actual returned value with the ‘#==` operator.
29 30 31 32 33 34 35 36 |
# File 'lib/assay/return_assay.rb', line 29 def self.fail?(returns, *arguments) #:yield: begin result = yield(*arguments) returns != result rescue Exception true end end |
.pass?(returns, *arguments) ⇒ Boolean
Check that a block returns a specific value comparing the returns
argument and actual returned value with the ‘#==` operator.
15 16 17 18 19 20 21 22 |
# File 'lib/assay/return_assay.rb', line 15 def self.pass?(returns, *arguments) #:yield: begin result = yield(*arguments) returns == result rescue Exception false end end |