Class: Sinclair::Matchers::ChangeClassMethodOn Private

Inherits:
ChangeMethodOn show all
Defined in:
lib/sinclair/matchers/change_class_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 class method was changed by the call of a block

This is used with a RSpec DSL method
change_class_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(target, method_name) ⇒ ChangeClassMethodOn

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

Parameters:

  • target (Class)

    Class where the class method should be added to

  • method_name (Symbol, String)

    method name



18
19
20
21
# File 'lib/sinclair/matchers/change_class_method_on.rb', line 18

def initialize(target, method_name)
  @klass = target
  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.

Return expectaton description

Returns:

  • (String)


26
27
28
# File 'lib/sinclair/matchers/change_class_method_on.rb', line 26

def description
  "change class method '#{method_name}' on #{klass}"
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)


33
34
35
36
# File 'lib/sinclair/matchers/change_class_method_on.rb', line 33

def failure_message_for_should
  "expected class method '#{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)


41
42
43
# File 'lib/sinclair/matchers/change_class_method_on.rb', line 41

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