parent
e20604ac02
commit
5b5c9f45d9
|
@ -74,6 +74,11 @@ module Draper
|
|||
end
|
||||
alias_method :is_a?, :kind_of?
|
||||
|
||||
def replace(other)
|
||||
decorated_collection.replace(other)
|
||||
self
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# @return the collection being decorated.
|
||||
|
|
|
@ -278,5 +278,21 @@ module Draper
|
|||
end
|
||||
end
|
||||
|
||||
describe "#replace" do
|
||||
it "replaces the decorated collection" do
|
||||
decorator = CollectionDecorator.new([Product.new])
|
||||
replacement = [:foo, :bar]
|
||||
|
||||
decorator.replace replacement
|
||||
expect(decorator).to match_array replacement
|
||||
end
|
||||
|
||||
it "returns itself" do
|
||||
decorator = CollectionDecorator.new([Product.new])
|
||||
|
||||
expect(decorator.replace([:foo, :bar])).to be decorator
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue