Sha256: bec7eedf7be2020ea121d676923f7dc81f29a8058f229bea80fa12248dee3dda
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
require_relative 'execution_assay' # Assert that a block of code returns a specific result, also # fails if an error is raised in the block. # class ReturnAssay < ExecutionAssay register :returns # # Check that a block returns a specific value comparing # the +returns+ argument and actual returned value with # the `#==` operator. # def self.pass?(returns, *arguments) #:yield: begin result = yield(*arguments) returns == result rescue Exception false end end # # Check that a block does NOT return a specific value comparing # the +returns+ argument and actual returned value with # the `#==` operator. # def self.fail?(returns, *arguments) #:yield: begin result = yield(*arguments) returns != result rescue Exception true end end ## ## ## #def self.assert_message(*arguments, &block) # "#{block}.call(*#{arguments.inspect})" #end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
assay-0.4.1 | lib/assay/return_assay.rb |
assay-0.4.0 | lib/assay/return_assay.rb |