Sha256: e98ee7e13369193a228dbcd54a8a3bc3b4641416a85e3d98fd264b92784cf4a4
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module ConvenientService module RSpec module Matchers module Custom class HaveAliasMethod def initialize(alias_name, original_name) @alias_name = alias_name @original_name = original_name end 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 def description "have alias method `#{alias_name}` for `#{original_name}`" end def failure_message "expected `#{object.class}` to have alias method `#{alias_name}` for `#{original_name}`" end def failure_message_when_negated "expected `#{object.class}` NOT to have alias method `#{alias_name}` for `#{original_name}`" end private attr_reader :object, :alias_name, :original_name end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
convenient_service-0.14.0 | lib/convenient_service/rspec/matchers/custom/have_alias_method.rb |
convenient_service-0.13.0 | lib/convenient_service/rspec/matchers/custom/have_alias_method.rb |