Sha256: 46919520cfe5c6ce00f562b797ba74b217056d75b1cfd1b9128bd2a54c458611
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require 'matchi/matchers_base' unless defined?(::Matchi::MatchersBase) # Namespace for the Matchi library. module Matchi # Collection of matchers. module Matchers # **Type/class** matcher. module BeInstanceOf # The matcher. class Matcher include MatchersBase # Initialize the matcher with an object. # # @example A string matcher # Matchi::BeInstanceOf.new(String) # # @param expected [#object_id] An expected class. def initialize(expected) @expected = expected end # @example Is it an instance of string? # be_instance_of = Matchi::BeInstanceOf.new(String) # be_instance_of.matches? { 'foo' } # => true # # @yieldreturn [#instance_of?] the actual value to compare to the # expected one. # # @return [Boolean] Comparison between actual and expected values. def matches? yield.instance_of?(@expected) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
matchi-rspec-0.1.3 | lib/matchi/rspec/be_instance_of.rb |
matchi-rspec-0.1.2 | lib/matchi/rspec/be_instance_of.rb |