spec/module/collections_ennumerable_spec.rb in ampere-1.2.1 vs spec/module/collections_ennumerable_spec.rb in ampere-1.2.2
- old
+ new
@@ -33,9 +33,21 @@
"John F. Kennedy" ,
"Jimmy Carter"
]
end
+ it 'should lazily evaluate the #[] method' do
+ presidents = President.all
+
+ presidents[2].name.should eq('Abraham Lincoln')
+ presidents[2].name.should eq('Abraham Lincoln')
+ end
+
+ it 'should be comparable to an array' do
+ President.all.should == President.all.to_a
+ President.all.should_not be(President.all.to_a)
+ end
+
# These are just a handful of methods to ensure that the Enumerable module is
# being included correctly. They can safely be factored out since the #each
# one above should cover Enumerable if it's being included correctly.
it 'should implement the #all? method correctly' do
President.all.all? {|p| p.party != 'Green'}.should be_true