Class: Sinclair::Matchers::AddMethod

Inherits:
RSpec::Matchers::BuiltIn::BaseMatcher
  • Object
show all
Defined in:
lib/sinclair/matchers/add_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method = nil) ⇒ AddMethod

Returns a new instance of AddMethod.



11
12
13
# File 'lib/sinclair/matchers/add_method.rb', line 11

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

Instance Attribute Details

#method ⇒ Object (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/sinclair/matchers/add_method.rb', line 4

def method
  @method
end

Instance Method Details

#equal?(other) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/sinclair/matchers/add_method.rb', line 19

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

#matches?(_actual) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (SyntaxError)


6
7
8
9
# File 'lib/sinclair/matchers/add_method.rb', line 6

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

#supports_block_expectations? ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/sinclair/matchers/add_method.rb', line 24

def supports_block_expectations?
  true
end

#to(instance = nil) ⇒ Object



15
16
17
# File 'lib/sinclair/matchers/add_method.rb', line 15

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