1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

refs #30 specs for new pagination helper

This commit is contained in:
Akira Matsuda 2011-02-27 20:28:00 +09:00
parent afc7dc1b44
commit 468fccfa39
2 changed files with 37 additions and 6 deletions

View file

@ -13,7 +13,7 @@ feature 'Users' do
page.should have_content '1'
end
within 'span.next' do
click_link 'Next »'
click_link 'Next '
end
end
@ -21,8 +21,8 @@ feature 'Users' do
within 'span.page.current' do
page.should have_content '2'
end
within 'span.page.last' do
click_link '4'
within 'span.last' do
click_link 'Last »'
end
end
@ -31,7 +31,7 @@ feature 'Users' do
page.should have_content '4'
end
within 'span.prev' do
click_link '« Prev'
click_link ' Prev'
end
end
@ -39,6 +39,15 @@ feature 'Users' do
within 'span.page.current' do
page.should have_content '3'
end
within 'span.first' do
click_link '« First'
end
end
within 'nav.pagination' do
within 'span.page.current' do
page.should have_content '1'
end
end
end
end

View file

@ -60,6 +60,28 @@ describe 'Kaminari::Helpers' do
end
end
describe '#next?' do
context 'page == current_page + 1' do
subject { Paginator::PageProxy.new({:current_page => 52}, 53, nil) }
its(:next?) { should be_true }
end
context 'page != current_page + 1' do
subject { Paginator::PageProxy.new({:current_page => 52}, 77, nil) }
its(:next?) { should_not be_true }
end
end
describe '#prev?' do
context 'page == current_page - 1' do
subject { Paginator::PageProxy.new({:current_page => 77}, 76, nil) }
its(:prev?) { should be_true }
end
context 'page != current_page + 1' do
subject { Paginator::PageProxy.new({:current_page => 77}, 80, nil) }
its(:prev?) { should_not be_true }
end
end
describe '#left_outer?' do
context 'current_page == left' do
subject { Paginator::PageProxy.new({:left => 3}, 3, nil) }
@ -67,7 +89,7 @@ describe 'Kaminari::Helpers' do
end
context 'current_page == left + 1' do
subject { Paginator::PageProxy.new({:left => 3}, 4, nil) }
its(:left_outer?) { should be_true }
its(:left_outer?) { should_not be_true }
end
context 'current_page == left + 2' do
subject { Paginator::PageProxy.new({:left => 3}, 5, nil) }
@ -82,7 +104,7 @@ describe 'Kaminari::Helpers' do
end
context 'num_pages - page == right' do
subject { Paginator::PageProxy.new({:num_pages => 10, :right => 3}, 7, nil) }
its(:right_outer?) { should be_true }
its(:right_outer?) { should_not be_true }
end
context 'num_pages - page < right' do
subject { Paginator::PageProxy.new({:num_pages => 10, :right => 3}, 8, nil) }