Permalink
Browse files

Stop delegating to the source collection

Closes #389
  • Loading branch information...
haines committed Dec 24, 2012
1 parent fd944cf commit 4960d49c931c04ea66f5441681e542dc88278156
Showing with 0 additions and 48 deletions.
  1. +0 −13 lib/draper/collection_decorator.rb
  2. +0 −35 spec/draper/collection_decorator_spec.rb
@@ -37,19 +37,6 @@ def find(*args, &block)
end
end
- def method_missing(method, *args, &block)
- source.send(method, *args, &block)
- end
-
- def respond_to?(method, include_private = false)
- super || source.respond_to?(method, include_private)
- end
-
- def kind_of?(klass)
- super || source.kind_of?(klass)
- end
- alias_method :is_a?, :kind_of?
-
def ==(other)
source == (other.respond_to?(:source) ? other.source : other)
end
@@ -213,17 +213,6 @@
end
end
- describe "#respond_to?" do
- it "returns true for its own methods" do
- subject.should respond_to :decorated_collection
- end
-
- it "returns true for the wrapped collection's methods" do
- source.stub(:respond_to?).with(:whatever, true).and_return(true)
- subject.respond_to?(:whatever, true).should be_true
- end
- end
-
it "delegates array methods to the decorated collection" do
subject.stub decorated_collection: []
subject.decorated_collection.should_receive(:[]).with(42).and_return(:the_answer)
@@ -264,30 +253,6 @@
end
end
- it "pretends to be the source class" do
- subject.kind_of?(source.class).should be_true
- subject.is_a?(source.class).should be_true
- end
-
- it "is still its own class" do
- subject.kind_of?(subject.class).should be_true
- subject.is_a?(subject.class).should be_true
- end
-
- describe "#method_missing" do
- before do
- class << source
- def page_number
- 42
- end
- end
- end
-
- it "proxies unknown methods to the source collection" do
- subject.page_number.should == 42
- end
- end
-
describe "#to_s" do
subject { Draper::CollectionDecorator.new(source, options) }
let(:source) { ["a", "b", "c"] }

0 comments on commit 4960d49

Please sign in to comment.