Sha256: c8baab371c8ed08081dd13f2cb95ac67693914cf67a05dffd666f59fed64d9b1
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require_relative 'assertion' # 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! # class ExecutionAssay < Assertion register :executes # # Check assertion. # def self.pass?(*arguments, &block) begin block.call(*arguments) rescue Exception false end end # # Check negated assertion. # def self.fail?(*arguments, &block) begin ! block.call(*arguments) rescue Exception true end end # #def self.assert!(*criteria, &block) # options = (Hash === criteria.last ? criteria.pop : {}) # assay = new(nil, *criteria) #, &block) # assay.assert!(options, &block) #end # #def self.refute!(*criteria, &block) # options = (Hash === criteria.last ? criteria.pop : {}) # assay = new(nil, *criteria) #, &block) # assay.refute!(options, &block) #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/execution_assay.rb |
assay-0.4.0 | lib/assay/execution_assay.rb |