Sha256: 9f23555cfac6925017b75813c19ad2cd685c763af7c9cc1f069ea6378821e68d

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

module Quickdraw::Matchers::ToRaise
	def to_raise(error = ::Exception)
		expectation_block = block

		begin
			expectation_block.call
		rescue error => e
			success!
			yield(e) if block_given?
			return
		rescue ::Exception => e
			return failure! { "expected `#{error.inspect}` to be raised but `#{e.class.inspect}` was raised" }
		end

		failure! { "expected #{error} to be raised but wasn't" }
	end

	def not_to_raise
		block.call
		success!
	rescue ::Exception => e
		failure! { "expected the block not to raise, but it raised `#{e.class}`" }
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quickdraw-0.1.0 lib/quickdraw/matchers/to_raise.rb