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
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #equal?(other) ⇒ Boolean
-
#initialize(method = nil) ⇒ AddMethod
constructor
A new instance of AddMethod.
- #matches?(_actual) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
- #to(instance = nil) ⇒ Object
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
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
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
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 |