From 90915c8ea49b97812af4dca6065e89af09440bf5 Mon Sep 17 00:00:00 2001 From: Yuki Nishijima Date: Mon, 2 Dec 2013 12:24:58 +0900 Subject: [PATCH] Put empty lines for readability [ci skip] --- spec/helpers/action_view_extension_spec.rb | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/helpers/action_view_extension_spec.rb b/spec/helpers/action_view_extension_spec.rb index 97ea48d..cd38c8e 100644 --- a/spec/helpers/action_view_extension_spec.rb +++ b/spec/helpers/action_view_extension_spec.rb @@ -6,6 +6,7 @@ describe 'Kaminari::ActionViewExtension' do 50.times {|i| User.create! :name => "user#{i}"} @users = User.page(1) end + subject { helper.paginate @users, :params => {:controller => 'users', :action => 'index'} } it { should be_a String } @@ -20,24 +21,29 @@ describe 'Kaminari::ActionViewExtension' do before do 50.times {|i| User.create! :name => "user#{i}"} end + context 'having previous pages' do before do @users = User.page(50) end + context 'the default behaviour' do subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} } it { should be_a String } it { should match(/rel="previous"/) } end + context 'overriding rel=' do subject { helper.link_to_previous_page @users, 'Previous', :rel => 'external', :params => {:controller => 'users', :action => 'index'} } it { should match(/rel="external"/) } end end + context 'the first page' do before do @users = User.page(1) end + subject { helper.link_to_previous_page @users, 'Previous', :params => {:controller => 'users', :action => 'index'} } it { should_not be } end @@ -47,24 +53,29 @@ describe 'Kaminari::ActionViewExtension' do before do 50.times {|i| User.create! :name => "user#{i}"} end + context 'having more page' do before do @users = User.page(1) end + context 'the default behaviour' do subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} } it { should be_a String } it { should match(/rel="next"/) } end + context 'overriding rel=' do subject { helper.link_to_next_page @users, 'More', :rel => 'external', :params => {:controller => 'users', :action => 'index'} } it { should match(/rel="external"/) } end end + context 'the last page' do before do @users = User.page(2) end + subject { helper.link_to_next_page @users, 'More', :params => {:controller => 'users', :action => 'index'} } it { should_not be } end @@ -75,6 +86,7 @@ describe 'Kaminari::ActionViewExtension' do before do @users = User.page(1).per(25) end + context 'having no entries' do subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} } it { should == 'No users found' } @@ -90,6 +102,7 @@ describe 'Kaminari::ActionViewExtension' do User.create! :name => 'user1' @users = User.page(1).per(25) end + subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} } it { should == 'Displaying 1 user' } @@ -104,6 +117,7 @@ describe 'Kaminari::ActionViewExtension' do 10.times {|i| User.create! :name => "user#{i}"} @users = User.page(1).per(25) end + subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} } it { should == 'Displaying all 10 users' } @@ -122,6 +136,7 @@ describe 'Kaminari::ActionViewExtension' do before do @users = User.page(1).per(25) end + subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} } it { should == 'Displaying users 1 - 25 of 50 in total' } @@ -135,6 +150,7 @@ describe 'Kaminari::ActionViewExtension' do before do @users = User.page(2).per(25) end + subject { helper.page_entries_info @users, :params => {:controller => 'users', :action => 'index'} } it { should == 'Displaying users 26 - 50 of 50 in total' } @@ -149,6 +165,7 @@ describe 'Kaminari::ActionViewExtension' do before do @addresses = User::Address.page(1).per(25) end + context 'having no entries' do subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} } it { should == 'No addresses found' } @@ -159,6 +176,7 @@ describe 'Kaminari::ActionViewExtension' do User::Address.create! @addresses = User::Address.page(1).per(25) end + subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} } it { should == 'Displaying 1 address' } @@ -173,6 +191,7 @@ describe 'Kaminari::ActionViewExtension' do 10.times {|i| User::Address.create!} @addresses = User::Address.page(1).per(25) end + subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} } it { should == 'Displaying all 10 addresses' } @@ -191,6 +210,7 @@ describe 'Kaminari::ActionViewExtension' do before do @addresses = User::Address.page(1).per(25) end + subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} } it { should == 'Displaying addresses 1 - 25 of 50 in total' } @@ -204,6 +224,7 @@ describe 'Kaminari::ActionViewExtension' do before do @addresses = User::Address.page(2).per(25) end + subject { helper.page_entries_info @addresses, :params => {:controller => 'addresses', :action => 'index'} } it { should == 'Displaying addresses 26 - 50 of 50 in total' } @@ -219,6 +240,7 @@ describe 'Kaminari::ActionViewExtension' do before do @numbers = Kaminari.paginate_array(%w{one two three}).page(1) end + subject { helper.page_entries_info @numbers } it { should == 'Displaying all 3 entries' } end @@ -228,6 +250,7 @@ describe 'Kaminari::ActionViewExtension' do before do 75.times {|i| User.create! :name => "user#{i}"} end + context 'the first page' do before do @users = User.page(1).per(25) @@ -238,6 +261,7 @@ describe 'Kaminari::ActionViewExtension' do it { should match(/rel="next"/) } it { should_not match(/rel="prev"/) } end + context 'the middle page' do before do @users = User.page(2).per(25) @@ -248,6 +272,7 @@ describe 'Kaminari::ActionViewExtension' do it { should match(/rel="next"/) } it { should match(/rel="prev"/) } end + context 'the last page' do before do @users = User.page(3).per(25)