Exception: Assay::ExecutionFailure

Inherits:
Assertion
  • Object
show all
Defined in:
lib/assay/assertions/execution_failure.rb

Overview

Assert that a block of coded executes without error.

ExecutionFailure is also the base class of the other block-executing assertion classes.

Direct Known Subclasses

RaiseFailure, ThrowFailure

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Assertion

assert, #assert, assertable_method, #assertion?, #fail?, #initialize, #negative?, #pass?, refute, #refute, #set_arguments, #set_negative, to_matcher

Constructor Details

This class inherits a constructor from Assay::Assertion

Class Method Details

.assertion_nameObject



11
12
13
# File 'lib/assay/assertions/execution_failure.rb', line 11

def self.assertion_name
  :execution
end

.fail?(_ = nil, &block) ⇒ Boolean

Check negated assertion.

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
# File 'lib/assay/assertions/execution_failure.rb', line 26

def self.fail?(_=nil, &block)
  begin
    block.call
    false
  rescue Exception
    true
  end
end

.pass?(_ = nil, &block) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/assay/assertions/execution_failure.rb', line 16

def self.pass?(_=nil, &block)
  begin
    block.call
    true
  rescue Exception
    false
  end
end

Instance Method Details

#to_sObject



36
37
38
39
40
41
42
# File 'lib/assay/assertions/execution_failure.rb', line 36

def to_s
  if @_negated
    "Expected procedure to raise an exception"
  else
    "Expected procedure to execute successfully"
  end
end