class RSpec::Sugar::Matchers::HaveAliases
Attributes
alias_methods[R]
cause[R]
method[R]
Public Class Methods
new(method, *alias_methods)
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 12 def initialize method, *alias_methods @method = method @alias_methods = alias_methods.flatten @cause = [] end
Public Instance Methods
cause_msg()
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 34 def cause_msg cause[0..3].join('.') end
failure_message()
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 38 def failure_message "Expected aliases to exist, but: #{cause_msg}" end
is_alias?(obj, alias_meth)
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 30 def is_alias? obj, alias_meth obj.respond_to? alias_meth end
matches?(obj, options={})
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 18 def matches? obj, options={} if !obj.respond_to? method cause << "Method ##{method} to alias does NOT exist" return nil end alias_methods.each do |method| cause << "Alias method ##{method} does NOT exist" if !is_alias? obj, alias_meth end cause.empty? end
negative_failure_message()
click to toggle source
# File lib/sugar-high/rspec/matchers/have_aliases.rb, line 42 def negative_failure_message "Did not expect aliases to exist but, #{cause_msg}".gsub /NOT/, '' end