Sha256: c9e2309ce7c76992dacc8e4034a0cd134be75f5e9da71f60e71e6c5bc1d09de2

Contents?: true

Size: 1.34 KB

Versions: 32

Compression:

Stored size: 1.34 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestPager < Test::Unit::TestCase
  context "pagination enabled" do
    setup do
      stub(Jekyll).configuration do
        Jekyll::DEFAULTS.merge({
          'source'      => source_dir, 
          'destination' => dest_dir,
          'paginate'    => 2
        })
      end

      @config = Jekyll.configuration
      @site = Site.new(@config)
      @posts = @site.read_posts('')
    end

    should "calculate number of pages" do
      assert_equal(2, Pager.calculate_pages(@posts, @config['paginate']))
    end

    should "create first pager" do
      pager = Pager.new(@config, 1, @posts)
      assert_equal(@config['paginate'].to_i, pager.posts.size)
      assert_equal(2, pager.total_pages)
      assert_nil(pager.previous_page)
      assert_equal(2, pager.next_page)
    end
  
    should "create second pager" do
      pager = Pager.new(@config, 2, @posts)
      assert_equal(@posts.size - @config['paginate'].to_i, pager.posts.size)
      assert_equal(2, pager.total_pages)
      assert_equal(1, pager.previous_page)
      assert_nil(pager.next_page)
    end
    
    should "not create third pager" do
      assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
    end
    
    should "report that pagination is enabled" do
      assert Pager.pagination_enabled?(@config, 'index.html')
    end
  end
end

Version data entries

32 entries across 32 versions & 15 rubygems

Version Path
Chrononaut-hyde-0.1.0 test/test_pager.rb
Chrononaut-hyde-0.1.1 test/test_pager.rb
PerfectlyNormal-jekyll-0.5.3 test/test_pager.rb
codeslinger-jekyll-0.5.2 test/test_pager.rb
codeslinger-jekyll-0.5.3 test/test_pager.rb
codeslinger-jekyll-0.5.4 test/test_pager.rb
mojombo-jekyll-0.5.2 test/test_pager.rb
mojombo-jekyll-0.5.3 test/test_pager.rb
nirvdrum-jekyll-0.6.0 test/test_pager.rb
pol-hyde-0.1.2 test/test_pager.rb
pol-hyde-0.1.3 test/test_pager.rb
rfelix-jekyll-0.5.4 test/test_pager.rb
sixones-jekyll-0.5.2.2 test/test_pager.rb
sixones-jekyll-0.5.2 test/test_pager.rb
tekin-jekyll-0.5.2 test/test_pager.rb
tomafro-jekyll-0.5.2.1 test/test_pager.rb
tomafro-jekyll-0.5.3.1 test/test_pager.rb
tomafro-jekyll-0.5.3.2 test/test_pager.rb
tomafro-jekyll-0.5.3.3 test/test_pager.rb
tomafro-jekyll-0.5.3.5 test/test_pager.rb