diff --git a/lib/draper/decorated_enumerable_proxy.rb b/lib/draper/decorated_enumerable_proxy.rb index b4914de..780f0da 100644 --- a/lib/draper/decorated_enumerable_proxy.rb +++ b/lib/draper/decorated_enumerable_proxy.rb @@ -21,6 +21,11 @@ module Draper def respond_to?(method) super || @wrapped_collection.respond_to?(method) end + + def kind_of?(klass) + super || @wrapped_collection.kind_of?(klass) + end + alias :is_a? :kind_of? def ==(other) @wrapped_collection == other diff --git a/spec/draper/base_spec.rb b/spec/draper/base_spec.rb index 6a5e18b..d0214fd 100644 --- a/spec/draper/base_spec.rb +++ b/spec/draper/base_spec.rb @@ -314,6 +314,26 @@ describe Draper::Base do subject = ProductDecorator.decorate(paged_array) subject[0].should be_instance_of ProductDecorator end + + context "pretends to be of kind of wrapped collection class" do + subject { ProductDecorator.decorate(paged_array) } + + it "#kind_of? DecoratedEnumerableProxy" do + subject.should be_kind_of Draper::DecoratedEnumerableProxy + end + + it "#is_a? DecoratedEnumerableProxy" do + subject.is_a?(Draper::DecoratedEnumerableProxy).should be_true + end + + it "#kind_of? Array" do + subject.should be_kind_of Array + end + + it "#is_a? Array" do + subject.is_a?(Array).should be_true + end + end context '#all' do it "should return a decorated collection" do