Sha256: 159620533c9cdaaf7d660fb888fe0a8728ca9d1e4d3396257395a185534b875f
Contents?: true
Size: 398 Bytes
Versions: 2
Compression:
Stored size: 398 Bytes
Contents
# frozen_string_literal: true # Returns a Boolean for whether the block raises the Exception expected # # throws?(StandardError) { raise } # => true # throws?(NameError) { raise NameError } # => true # throws?(NoMethodError) { raise NameError } # => false # throws?(StandardError) { 'foo' } # => false def throws?(exception) # &block yield false rescue Exception => e e.is_a? exception end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeset-0.7.1 | lib/helpers/throws.rb |
activeset-0.7.0 | lib/helpers/throws.rb |