spec/picky-client/convenience_spec.rb in picky-client-4.11.3 vs spec/picky-client/convenience_spec.rb in picky-client-4.12.0
- old
+ new
@@ -91,11 +91,11 @@
class ARClass
attr_reader :id
def initialize id
@id = id
end
- def self.find ids, options = {}
+ def self.find_by_id ids, options = {}
ids.map { |id| new(id) }
end
def == other
self.id == other.id
end
@@ -111,10 +111,14 @@
end
it "keeps the ids by default" do
@results.populate_with(ARClass) { |ar_instance| ar_instance.id.to_s }
@results.ids.should_not be_empty
end
+ it "should allow you to override the finder method you use" do
+ ARClass.should_receive(:find_by_id).and_return((1..20).map { |id| ARClass.new(id) })
+ @results.populate_with ARClass, :finder_method => :find_by_id
+ end
end
describe 'replace_ids_with' do
before(:each) do
@results = {
@@ -208,6 +212,6 @@
@convenience.empty?.should == false
end
end
end
-end
\ No newline at end of file
+end