Sha256: 7484b913f58dcb4b579ae1eae150aef4965f72ad0d5b8ae563ed2f041eadefa2

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

class Sinclair
  module Matchers
    class AddMethod < RSpec::Matchers::BuiltIn::BaseMatcher
      attr_reader :method

      def matches?(_actual)
        raise SyntaxError, 'You should specify which instance the method is being added to' \
          "add_method(:#{method}).to(instance)"
      end

      def initialize(method = nil)
        @method = method
      end

      def to(instance = nil)
        AddMethodTo.new(instance, method)
      end

      def equal?(other)
        return unless other.class == self.class
        other.method == method
      end

      def supports_block_expectations?
        true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinclair-1.1.0 lib/sinclair/matchers/add_method.rb