spec/picky-client/convenience_spec.rb in picky-client-3.3.3 vs spec/picky-client/convenience_spec.rb in picky-client-3.4.0
- old
+ new
@@ -10,11 +10,11 @@
:offset => 123,
:total => 12345,
:duration => 0.12345
}.extend Picky::Convenience
end
-
+
describe "entries" do
context "default" do
context "without block" do
it "returns 20 values" do
@convenience.entries.should == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
@@ -73,11 +73,11 @@
@convenience.entries(30).should == (2..24).to_a
end
end
end
end
-
+
describe "populate_with" do
before(:each) do
@results = {
:allocations => [[nil, nil, nil, nil, [1,2,3,4,5,6,7,8]],
[nil, nil, nil, nil, [9,10,11,12,13,14,15,16]],
@@ -85,11 +85,11 @@
],
:offset => 123,
:duration => 0.123,
:count => 1234
}.extend Picky::Convenience
-
+
class ARClass
attr_reader :id
def initialize id
@id = id
end
@@ -107,11 +107,15 @@
end
it "should populate correctly with a render block" do
@results.populate_with(ARClass) { |ar_instance| ar_instance.id.to_s }
@results.entries.should == (1..20).map { |id| id.to_s } # "rendering" using to_s
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
end
-
+
describe 'replace_ids_with' do
before(:each) do
@results = {
:allocations => [[nil, nil, nil, nil, [1,2,3,4,5,6,7,8]],
[nil, nil, nil, nil, [9,10,11,12,13,14,15,16]],
\ No newline at end of file