Skip to content

Instantly share code, notes, and snippets.

@johnnymo87
Last active August 29, 2015 13:55
Show Gist options
  • Save johnnymo87/8760346 to your computer and use it in GitHub Desktop.
Save johnnymo87/8760346 to your computer and use it in GitHub Desktop.
Pagination: Why does length and count return different values?
# in spec/models/project_spec.rb
describe '#paginate' do
before(:all) { 9.times { FactoryGirl.create(:project) } }
after(:all) { User.delete_all }
it 'returns paginated values' do
Project.paginate(page: 1).should eq Project.first 5
Project.paginate(page: 1).length.should eq 5
Project.paginate(page: 1).count.should eq 9
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment