Sha256: 6bd40003ecce7b03ee4dfe995c2891926c63cf0178c4aa0c7d7847cb9b0661af

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

require "spec_helper"

describe Paginate::Renderer::More do
  before do
    Paginate.configure do |config|
      config.param_name = :page
      config.size  = 10
    end

    I18n.locale = :en

    @renderer = Paginate::Renderer::More.new(nil, {
      collection: Array.new(11),
      page: 1,
      fullpath: "/some/path"
    })
  end

  it { expect(@renderer.render).to be_html_safe }
  it { expect(@renderer.more_label).to eql(I18n.t("paginate.more")) }

  context "when have no next page" do
    it "returns nil" do
      allow(@renderer.processor).to receive :next_page?
      expect(@renderer.render).to be_nil
    end
  end

  context "when have next page" do
    it "returns html" do
      html = Nokogiri::HTML(@renderer.render)
      selector = "p.paginate > a.more"

      expect(html.css(selector).text).to eql(@renderer.more_label)
      expect(html.css(selector).first[:href]).to eql(@renderer.next_url)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-4.0.0 spec/paginate/renderer/more_spec.rb