Sha256: a10084c9550f225e574be2fea695d390d28883728363826048620850a10f93d3

Contents?: true

Size: 1.47 KB

Versions: 22

Compression:

Stored size: 1.47 KB

Contents

require 'helper'

class TestRelatedPosts < Test::Unit::TestCase
  context "building related posts without lsi" do
    setup do
      stub(Jekyll).configuration do
        Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir,
                                               'destination' => dest_dir})
      end
      @site = Site.new(Jekyll.configuration)
    end

    should "use the most recent posts for related posts" do
      @site.reset
      @site.read

      last_post     = @site.posts.last
      related_posts = Jekyll::RelatedPosts.new(last_post).build

      last_10_recent_posts = (@site.posts.reverse - [last_post]).first(10)
      assert_equal last_10_recent_posts, related_posts
    end
  end

  context "building related posts with lsi" do
    setup do
      stub(Jekyll).configuration do
        Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir,
                                               'destination' => dest_dir,
                                               'lsi' => true})
      end
      any_instance_of(Jekyll::RelatedPosts) { |i| stub(i).display }
      @site = Site.new(Jekyll.configuration)
    end

    should "use lsi for the related posts" do
      @site.reset
      @site.read
      require 'classifier'
      any_instance_of(::Classifier::LSI) do |c|
        stub(c).find_related { @site.posts[-1..-9] }
        stub(c).build_index
      end
      assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
jekyll-2.2.0 test/test_related_posts.rb
jekyll-2.1.1 test/test_related_posts.rb
jekyll-2.1.0 test/test_related_posts.rb
jekyll-2.0.3 test/test_related_posts.rb
jekyll-2.0.2 test/test_related_posts.rb
jekyll-2.0.1 test/test_related_posts.rb
jekyll-2.0.0 test/test_related_posts.rb
jekyll-2.0.0.rc1 test/test_related_posts.rb
jekyll-2.0.0.alpha.3 test/test_related_posts.rb
jekyll-1.5.1 test/test_related_posts.rb
jekyll-2.0.0.alpha.2 test/test_related_posts.rb
jekyll-1.5.0 test/test_related_posts.rb
jekyll-2.0.0.alpha.1 test/test_related_posts.rb
jekyll-1.4.3 test/test_related_posts.rb
jekyll-1.4.2 test/test_related_posts.rb
jekyll-1.4.1 test/test_related_posts.rb
jekyll-1.4.0 test/test_related_posts.rb
jekyll-1.3.1 test/test_related_posts.rb
jekyll-1.3.0 test/test_related_posts.rb
jekyll-1.3.0.rc test/test_related_posts.rb