Class: Sinclair::Matchers::AddMethodTo Private
- Inherits:
-
RSpec::Matchers::BuiltIn::BaseMatcher
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- Sinclair::Matchers::AddMethodTo
- 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.
AddMethodTo 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.
-
#equal?(other) ⇒ Boolean
(also: #==)
private
Checkes if another instnce is equal self.
-
#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) ⇒ AddMethodTo
constructor
private
Returns a new instance of AddMethodTo.
-
#matches?(event_proc) ⇒ Boolean
private
Checks if expectation is true or not.
-
#supports_block_expectations? ⇒ Boolean
private
definition needed for block matchers.
Constructor Details
#initialize(klass, method) ⇒ AddMethodTo #initialize(instance, 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
49 50 51 52 53 54 55 56 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 49 def initialize(target, method) if target.is_a?(Class) @klass = target else @instance = target end @method = 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
63 64 65 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 63 def description "add method '#{method}' to #{klass} instances" end |
#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
108 109 110 111 112 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 108 def equal?(other) return unless other.class == self.class other.method == method && other.instance == instance 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
72 73 74 75 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 72 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
82 83 84 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 82 def "expected '#{method}' not to be added to #{klass} but it was" 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
91 92 93 94 95 96 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 91 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
99 100 101 |
# File 'lib/sinclair/matchers/add_method_to.rb', line 99 def supports_block_expectations? true end |