lib/sugar-high/rspec/matchers/have_aliases.rb in sugar-high-0.6.3 vs lib/sugar-high/rspec/matchers/have_aliases.rb in sugar-high-0.7.0

- old
+ new

@@ -2,31 +2,31 @@ module Sugar end end module RSpec::Sugar - module Matchers + module Matchers class HaveAliases attr_reader :method, :alias_methods, :cause def initialize method, *alias_methods @method = method @alias_methods = alias_methods.flatten @cause = [] end - def matches? obj, options={} + 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? + + alias_methods.each do |method| + cause << "Alias method ##{method} does NOT exist" if !is_alias? obj, alias_meth + end + cause.empty? end def is_alias? obj, alias_meth obj.respond_to? alias_meth end @@ -39,10 +39,10 @@ "Expected aliases to exist, but: #{cause_msg}" end def negative_failure_message "Did not expect aliases to exist but, #{cause_msg}".gsub /NOT/, '' - end + end end def have_aliases method, *alias_methods HaveAliases.new method, *alias_methods end