Class: Sinclair::Matchers::AddInstanceMethodTo Private
- Inherits:
-
AddMethodTo
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- 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
(also: #failure_message)
private
Returns message on expectation failure.
-
#failure_message_for_should_not ⇒ String
(also: #failure_message_when_negated)
private
Returns message on expectation failure for negative expectation.
-
#initialize(target, method) ⇒ AddInstanceMethodTo
constructor
private
Returns a new instance of AddInstanceMethodTo.
Methods inherited from AddMethodTo
#equal?, #matches?, #supports_block_expectations?
Constructor Details
#initialize(klass, method) ⇒ AddInstanceMethodTo #initialize(instance, method) ⇒ 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
44 45 46 47 48 49 50 51 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 44 def initialize(target, method) if target.is_a?(Class) @klass = target else @instance = target end super(method) 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
56 57 58 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 56 def description "add method '#{method}' to #{klass} instances" end |
#failure_message_for_should ⇒ String Also known as: failure_message
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
63 64 65 66 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 63 def "expected '#{method}' to be added to #{klass} but " \ "#{@initial_state ? 'it already existed' : "it didn't"}" end |
#failure_message_for_should_not ⇒ String Also known as: failure_message_when_negated
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
71 72 73 |
# File 'lib/sinclair/matchers/add_instance_method_to.rb', line 71 def "expected '#{method}' not to be added to #{klass} but it was" end |