Exception: ExecutionAssay

Inherits:
Assertion show all
Defined in:
lib/assay/execution_assay.rb

Overview

Assert that a block of coded executes without error and does not return nil or false.

NOTE: To test only for successful execution regardless of return value use a negated RaiseAssay on the Exception class. But generally this would be pretty silly, if you think about it, this is exactly what testing is for!

Direct Known Subclasses

ReturnAssay, ThrowAssay

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Constants included from Assay::Assertable

Assay::Assertable::SIZE_LIMIT

Class Method Summary collapse

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(*arguments, &block) ⇒ Object



54
55
56
# File 'lib/assay/execution_assay.rb', line 54

def self.assert_message(*arguments, &block)
  "#{block}.call(*#{arguments.inspect})"
end

.fail?(*arguments, &block) ⇒ Boolean

Check negated assertion.

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/assay/execution_assay.rb', line 29

def self.fail?(*arguments, &block)
  begin
    ! block.call(*arguments)
  rescue Exception
    true
  end
end

.pass?(*arguments, &block) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/assay/execution_assay.rb', line 18

def self.pass?(*arguments, &block)
  begin
    block.call(*arguments)
  rescue Exception
    false
  end
end