Sha256: 544636f3ea54344b31f0fc6fadd82acfff742671a070399777331885c19aa97f

Contents?: true

Size: 429 Bytes

Versions: 2

Compression:

Stored size: 429 Bytes

Contents

module Expect
  module Matcher
    # Provides the implementation for `raise_exception`.
    class RaiseException < BasicObject
      def initialize(expected)
        @expected = expected
      end

      # @return [Boolean] Comparison between actual and expected values.
      def matches?
        begin
          yield
        rescue @expected
          true
        else
          false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
expect-0.0.2 lib/expect/matcher/raise_exception.rb
expect-0.0.1 lib/expect/matcher/raise_exception.rb