From 32aceb7b7a9e37a4fd5a07f3d21eaaf7ba339e64 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 25 Apr 2011 17:14:00 +0900 Subject: [PATCH] spec for last_page? and first_page? Conflicts: spec/models/scopes_spec.rb --- spec/models/scopes_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/models/scopes_spec.rb b/spec/models/scopes_spec.rb index 5c3717b..e08fe34 100644 --- a/spec/models/scopes_spec.rb +++ b/spec/models/scopes_spec.rb @@ -94,6 +94,30 @@ describe Kaminari::ActiveRecordExtension do end end + describe '#first_page?' do + context 'on first page' do + subject { User.page(1).per(10) } + its(:first_page?) { should == true } + end + + context 'not on first page' do + subject { User.page(5).per(10) } + its(:first_page?) { should == false } + end + end + + describe '#last_page?' do + context 'on last page' do + subject { User.page(10).per(10) } + its(:last_page?) { should == true } + end + + context 'not on last page' do + subject { User.page(1).per(10) } + its(:last_page?) { should == false } + end + end + describe '#count' do context 'page 1' do subject { User.page }