Class: Sinclair::Matchers::AddInstanceMethodTo Private
- Inherits:
-
AddMethodTo
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- Base
- AddMethodTo
- Sinclair::Matchers::AddInstanceMethodTo
- Defined in:
- lib/sinclair/matchers/add_instance_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.
AddInstanceMethodTo checks whether a method was or not added by the call of a block
This is used with a RSpec DSL method add_method(method_name).to(class_object)
Instance Method Summary collapse
-
#description ⇒ String
private
Returnst expectaton description.
-
#failure_message_for_should ⇒ String
private
Returns message on expectation failure.
-
#failure_message_for_should_not ⇒ String
private
Returns message on expectation failure for negative expectation.
-
#initialize(target, method_name) ⇒ AddInstanceMethodTo
constructor
private
A new instance of AddInstanceMethodTo.
Methods included from MethodTo
#failure_message, #failure_message_when_negated, #matches?
Methods inherited from Base
#equal?, #supports_block_expectations?
Constructor Details
#initialize(klass, method_name) ⇒ AddInstanceMethodTo #initialize(instance, method_name) ⇒ AddInstanceMethodTo
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 AddInstanceMethodTo.
42 43 44 45 46 47 48 49 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 42 def initialize(target, method_name) if target.is_a?(Class) @klass = target else @instance = target end super(method_name) end |
Instance Method Details
#description ⇒ String
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.
Returnst expectaton description
54 55 56 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 54 def description "add method '#{method_name}' to #{klass} instances" end |
#failure_message_for_should ⇒ String
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 message on expectation failure
61 62 63 64 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 61 def "expected '#{method_name}' to be added to #{klass} but " \ "#{initial_state ? 'it already existed' : "it didn't"}" end |
#failure_message_for_should_not ⇒ String
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 message on expectation failure for negative expectation
69 70 71 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 69 def "expected '#{method_name}' not to be added to #{klass} but it was" end |