Sha256: c20ca90367370deef3b083bbc018b8f5b1215fa9841f8fd34d4d4e165dcc5cb8

Contents?: true

Size: 967 Bytes

Versions: 21

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

class Sinclair
  module Matchers
    # @abstract
    # @api private
    #
    # Base class for all matchers
    class Base < RSpec::Matchers::BuiltIn::BaseMatcher
      # @param method_name [String,Symbol] the method, to be checked, name
      def initialize(method_name)
        @method_name = method_name.to_sym
      end

      # definition needed for block matchers
      #
      # @return [Boolean]
      def supports_block_expectations?
        true
      end

      # Checkes if another instnce is equal self
      #
      # @return [Boolean]
      def equal?(other)
        return unless other.class == self.class

        other.method_name == method_name &&
          other.try(:klass) == try(:klass)
      end

      alias == equal?

      protected

      # @method method_name
      # @private
      #
      # The method, to be checked, name
      #
      # @return [Symbol]
      attr_reader :method_name
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sinclair-2.1.1 lib/sinclair/matchers/base.rb
sinclair-2.1.0 lib/sinclair/matchers/base.rb
sinclair-2.0.1 lib/sinclair/matchers/base.rb
sinclair-2.0.0 lib/sinclair/matchers/base.rb
sinclair-1.16.3 lib/sinclair/matchers/base.rb
sinclair-1.16.2 lib/sinclair/matchers/base.rb
sinclair-1.16.1 lib/sinclair/matchers/base.rb
sinclair-1.16.0 lib/sinclair/matchers/base.rb
sinclair-1.15.0 lib/sinclair/matchers/base.rb
sinclair-1.14.2 lib/sinclair/matchers/base.rb
sinclair-1.14.1 lib/sinclair/matchers/base.rb
sinclair-1.14.0 lib/sinclair/matchers/base.rb
sinclair-1.13.0 lib/sinclair/matchers/base.rb
sinclair-1.12.1 lib/sinclair/matchers/base.rb
sinclair-1.12.0 lib/sinclair/matchers/base.rb
sinclair-1.11.0 lib/sinclair/matchers/base.rb
sinclair-1.10.0 lib/sinclair/matchers/base.rb
sinclair-1.9.0 lib/sinclair/matchers/base.rb
sinclair-1.8.0 lib/sinclair/matchers/base.rb
sinclair-1.7.0 lib/sinclair/matchers/base.rb