Class: Sinclair::Matchers::AddMethodTo Abstract Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

Base class for add_method_to matcher

Author:

  • darthjee

Direct Known Subclasses

AddClassMethodTo, AddInstanceMethodTo

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ AddMethodTo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AddMethodTo.

Parameters:

  • method (SYmbol, String)

    method name



12
13
14
# File 'lib/sinclair/matchers/add_method_to.rb', line 12

def initialize(method)
  @method = method
end

Instance Method Details

#equal?(other) ⇒ Boolean Also known as: ==

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checkes if another instnce is equal self

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/sinclair/matchers/add_method_to.rb', line 35

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

  other.method == method &&
    other.klass == klass
end

#matches?(event_proc) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if expectation is true or not

Returns:

  • (Boolean)

    expectation check



19
20
21
22
23
24
25
# File 'lib/sinclair/matchers/add_method_to.rb', line 19

def matches?(event_proc)
  return false unless event_proc.is_a?(Proc)

  raise_block_syntax_error if block_given?
  perform_change(event_proc)
  added?
end

#supports_block_expectations?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

definition needed for block matchers

Returns:

  • (Boolean)


28
29
30
# File 'lib/sinclair/matchers/add_method_to.rb', line 28

def supports_block_expectations?
  true
end