Files
jekyll/test/test_related_posts.rb
Matt Rogers 770402d912 Also stub the building of the index
Since we don't actually use the index in getting the related posts from
the tests there's no need to build an index, which can take a long time
if the ruby bindings for the GSL library are not installed.
2013-05-08 22:33:20 -05:00

42 lines
1.3 KiB
Ruby

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
assert_equal @site.posts[0..9], Jekyll::RelatedPosts.new(@site.posts.last).build
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
@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