class ReturnAssay

Assert that a block of code returns a specific result, also fails if an error is raised in the block.

Public Class Methods

fail?(returns, *arguments) { || ... } click to toggle source

Check that a block does NOT return a specific value comparing the returns argument and actual returned value with the ‘#==` operator.

# 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) { || ... } click to toggle source

Check that a block returns a specific value comparing the returns argument and actual returned value with the ‘#==` operator.

# 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