Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAliasMethod
- Inherits:
-
Object
- Object
- ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAliasMethod
- Defined in:
- lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(alias_name, original_name) ⇒ HaveAliasMethod
constructor
A new instance of HaveAliasMethod.
- #matches?(object) ⇒ Boolean
Constructor Details
#initialize(alias_name, original_name) ⇒ HaveAliasMethod
Returns a new instance of HaveAliasMethod.
8 9 10 11 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb', line 8 def initialize(alias_name, original_name) @alias_name = alias_name @original_name = original_name end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb', line 29 def description "have alias method `#{alias_name}` for `#{original_name}`" end |
#failure_message ⇒ Object
33 34 35 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb', line 33 def "expected `#{object.class}` to have alias method `#{alias_name}` for `#{original_name}`" end |
#failure_message_when_negated ⇒ Object
37 38 39 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb', line 37 def "expected `#{object.class}` NOT to have alias method `#{alias_name}` for `#{original_name}`" end |
#matches?(object) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_alias_method.rb', line 13 def matches?(object) @object = object ## # TODO: Use `Utils::Object.duck_class` to support `have_alias_method` for classes. # return false unless Utils::Method.defined?(original_name, object.class, private: true) return false unless Utils::Method.defined?(alias_name, object.class, private: true) ## # https://stackoverflow.com/a/45640516/12201472 # object.method(alias_name).original_name == object.method(original_name).original_name end |