Class: Sinclair::Matchers::AddMethod
- Inherits:
-
RSpec::Matchers::BuiltIn::BaseMatcher
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- Sinclair::Matchers::AddMethod
- Defined in:
- lib/sinclair/matchers/add_method.rb
Overview
AddMethod is able to build an instance of Sinclair::Matchers::AddMethodTo
Instance Method Summary collapse
-
#equal?(other) ⇒ Boolean
(also: #==)
private
Checkes if another instnce is equal self.
-
#initialize(method) ⇒ AddMethod
constructor
private
Returns a new instance of AddMethod.
-
#matches?(_actual) ⇒ Boolean
abstract
private
Raise a warning on the usage as this is only a builder for AddMethodTo.
-
#supports_block_expectations? ⇒ Boolean
private
definition needed for block matchers.
-
#to(target = nil) ⇒ AddMethodTo
Creates a matcher AddMethodTo.
Constructor Details
#initialize(method) ⇒ AddMethod
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 AddMethod
24 25 26 |
# File 'lib/sinclair/matchers/add_method.rb', line 24 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
93 94 95 96 |
# File 'lib/sinclair/matchers/add_method.rb', line 93 def equal?(other) return unless other.class == self.class other.method == method end |
#matches?(_actual) ⇒ 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.
Raise a warning on the usage as this is only a builder for AddMethodTo
14 15 16 17 |
# File 'lib/sinclair/matchers/add_method.rb', line 14 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
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
84 85 86 |
# File 'lib/sinclair/matchers/add_method.rb', line 84 def supports_block_expectations? true end |
#to(klass) ⇒ AddMethodTo #to(instance) ⇒ AddMethodTo
Creates a matcher AddMethodTo
75 76 77 |
# File 'lib/sinclair/matchers/add_method.rb', line 75 def to(target = nil) AddMethodTo.new(target, method) end |