diff --git a/lib/draper/decoratable/equality.rb b/lib/draper/decoratable/equality.rb index 64679eb..a160bfa 100644 --- a/lib/draper/decoratable/equality.rb +++ b/lib/draper/decoratable/equality.rb @@ -9,6 +9,10 @@ module Draper other.respond_to?(:decorated?) && other.decorated? && other.respond_to?(:source) && self == other.source end + + def self.test(first, other) + first == other + end end end end diff --git a/lib/draper/decorator.rb b/lib/draper/decorator.rb index 1abebdc..65ec16b 100755 --- a/lib/draper/decorator.rb +++ b/lib/draper/decorator.rb @@ -163,7 +163,7 @@ module Draper # # @return [Boolean] def ==(other) - source.extend(Draper::Decoratable::Equality) == other + Draper::Decoratable::Equality.test(source, other) end # Checks if `self.kind_of?(klass)` or `source.kind_of?(klass)` diff --git a/spec/draper/decorator_spec.rb b/spec/draper/decorator_spec.rb index f85679d..9c45175 100755 --- a/spec/draper/decorator_spec.rb +++ b/spec/draper/decorator_spec.rb @@ -380,15 +380,6 @@ module Draper end describe "#==" do - it "ensures the source has a decoration-aware #==" do - source = Object.new - decorator = Decorator.new(source) - - expect(source).not_to be_a_kind_of Draper::Decoratable::Equality - decorator == :something - expect(source).to be_a_kind_of Draper::Decoratable::Equality - end - it "is true when source #== is true" do source = Model.new decorator = Decorator.new(source)