Sha256: ecdd8eb1e6b62b1d7653203b1ac7458eb98c5fe1047a96d2ec1c9b4378c63502

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 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
      @renderer.processor.stub :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-3.0.0 spec/paginate/renderer/more_spec.rb