require 'spec_helper' describe NeatPages::Helpers::Status do include ViewHelpers describe "#generate" do let(:pagination) { double() } context "with an empty pagination" do before { pagination.stub(:empty?).and_return(true) } let(:builder) { NeatPages::Helpers::Status.new(pagination, request_mock) } context "when generating the status" do specify { builder.generate.should be_empty } end end context "with a pagination out of bound" do before do pagination.stub(:empty?).and_return(false) pagination.stub(:out_of_bound?).and_return(true) end let(:builder) { NeatPages::Helpers::Status.new(pagination, request_mock) } context "when generating the status" do specify { builder.generate.should be_empty } end end context "with a 100 items pagination starting at 20 and having 10 items per page" do before do 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) end let(:builder) { NeatPages::Helpers::Status.new(pagination, request_mock) } context "when generating the status" do specify { builder.generate.should eql '21 to 30/100' } end end context "with a 23 items pagination starting at 20 and having 10 items per page" do before do 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(23) end let(:builder) { NeatPages::Helpers::Status.new(pagination, request_mock) } context "when generating the status" do specify { builder.generate.should eql '21 to 23/23' } end end end end