Sha256: 44c62738b7cca6be9c26dc6817c706cefeddb3e2f1861ea185c9c9788ac9274c
Contents?: true
Size: 1.12 KB
Versions: 11
Compression:
Stored size: 1.12 KB
Contents
module Kookaburra module Assertion # Custom exception class for assertion failures class Failure < Exception; end # Provides a mechanism for making assertions within your domain and window drivers # without creating a dependency on any specific testing framework. # # @param [Truthy] predicate The thing you are asserting should be `true` (or at least truthy). # @param [String] message Optional message to return if `predicate` is not `true` (or at least truthy). # @return [nil] if `predicate` does not evaluate to `false` or `nil` # @raise [Kookaburra::Assertion::Failure] if `predicate` evaluates to `false` or `nil` def assert(predicate, message = nil) return if predicate raise Failure, message rescue Failure => e raise Backtrace.clean(e) end # @private module Backtrace module_function def clean(exception) new_backtrace = exception.backtrace.dup new_backtrace.shift while new_backtrace.first.include?('lib/kookaburra/assertion.rb') exception.set_backtrace(new_backtrace) exception end end end end
Version data entries
11 entries across 11 versions & 1 rubygems