1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Merge pull request #95 from tmaier/issue-92

Overwrite #kind_of? and #is_a? in Draper::DecoratedEnumerableProxy
This commit is contained in:
Steve Klabnik 2012-01-05 09:58:43 -08:00
commit 1c9cb11f9e
2 changed files with 25 additions and 0 deletions

View file

@ -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

View file

@ -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