Class: Sinclair::Matchers::ChangeInstanceMethodOn Private

Inherits:
ChangeMethodOn show all
Defined in:
lib/sinclair/matchers/change_instance_method_on.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.

Checks if a method was changed by the call of a block

This is used with a RSpec DSL method
change_method(method_name).on(class_object)

Author:

  • darthjee

Instance Method Summary collapse

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) ⇒ ChangeInstanceMethodOn #initialize(instance, method_name) ⇒ ChangeInstanceMethodOn

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 ChangeInstanceMethodOn.

Overloads:

  • #initialize(klass, method_name) ⇒ ChangeInstanceMethodOn

    Parameters:

    • klass (Class)

      class where the method should be added to

  • #initialize(instance, method_name) ⇒ ChangeInstanceMethodOn

    Parameters:

    • instance (Object)

      instance of the class where the method should be added to

Parameters:

  • method_name (Symbol, String)

    method name



23
24
25
26
27
28
29
30
31
# File 'lib/sinclair/matchers/change_instance_method_on.rb', line 23

def initialize(target, method_name)
  if target.is_a?(Class)
    @klass = target
  else
    @instance = target
  end

  super(method_name)
end

Instance Method Details

#descriptionString

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

Returns:

  • (String)


36
37
38
# File 'lib/sinclair/matchers/change_instance_method_on.rb', line 36

def description
  "change method '#{method_name}' on #{klass} instances"
end

#failure_message_for_shouldString

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

Returns:

  • (String)


43
44
45
46
# File 'lib/sinclair/matchers/change_instance_method_on.rb', line 43

def failure_message_for_should
  "expected '#{method_name}' to be changed on #{klass} but " \
    "#{initial_state ? "it didn't" : "it didn't exist"}"
end

#failure_message_for_should_notString

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

Returns:

  • (String)


51
52
53
# File 'lib/sinclair/matchers/change_instance_method_on.rb', line 51

def failure_message_for_should_not
  "expected '#{method_name}' not to be changed on #{klass} but it was"
end