require 'spec_helper' describe NeatPages::Helpers do include ViewHelpers let(:pagination) { double() } let(:views) { Module.new { extend NeatPages::Helpers } } describe "#neat_pages_ajax_items" do before { views.stub(:render).and_return '[html_list_of_items]' } context "when rendering the ajax items" do specify { views.neat_pages_ajax_items('items').should eql '
[html_list_of_items]
' } end context "when rendering the ajax items for a table" do specify { views.neat_pages_ajax_items('items', wrapper: 'tbody').should eql '[html_list_of_items]' } end end describe "#neat_pages_navigation" do before do views.stub(:request).and_return(request_mock(host: 'testview.dev')) pagination.stub(:paginated?).and_return(true) pagination.stub(:current_page).and_return(3) pagination.stub(:next?).and_return(true) pagination.stub(:next_page).and_return(4) pagination.stub(:offset).and_return(20) pagination.stub(:per_page).and_return(10) pagination.stub(:previous?).and_return(true) pagination.stub(:previous_page).and_return(2) pagination.stub(:total_items).and_return(40) pagination.stub(:total_pages).and_return(4) views.stub(:pagination).and_return(pagination) end context "when rendering the navigation" do specify { views.neat_pages_navigation.should eql '' } end end describe "#neat_pages_status" do before do views.stub(:request).and_return(request_mock) pagination.stub(:empty?).and_return(false) pagination.stub(:out_of_bound?).and_return(false) pagination.stub(:offset).and_return(20) pagination.stub(:per_page).and_return(10) pagination.stub(:total_items).and_return(100) views.stub(:pagination).and_return(pagination) end context "when rendering the status" do specify { views.neat_pages_status.should eql '21 to 30/100' } end end end