Sha256: 7d24d2cf5535850e320a1d9d81514986de5076fbd75f8232b28448e741315e22
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
class Sinclair module Matchers # AddMethod is able to build an instance of Sinclair::Matchers::AddMethodTo class AddMethod < RSpec::Matchers::BuiltIn::BaseMatcher # as any matcher is expected to implement matches?, we raise a warning on the usage as # this is only a builder for AddMethodTo def matches?(_actual) raise SyntaxError, 'You should specify which instance the method is being added to' \ "add_method(:#{method}).to(instance)" end # @param method [String/Symbol] the method, to be checked, name def initialize(method) @method = method end # @return [AddMethodTo] the correct matcher # @overload to(klass) # @param [Class] klass # class where the method should be added to # # @overload to(instance) # @param [Object] instance # instance of the class where the method should be added to def to(target = nil) AddMethodTo.new(target, method) end def equal?(other) return unless other.class == self.class other.method == method end # definition needed for block matchers def supports_block_expectations? true end protected attr_reader :method end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinclair-1.1.1 | lib/sinclair/matchers/add_method.rb |