Wrap tests around Jekyll::RelatedPosts
This gives me more confidence that we're doing the right things when it comes to both the LSI and non-LSI cases and prevents regressions.
This commit is contained in:
parent
64f8a7b228
commit
1aa49fa734
|
@ -0,0 +1,40 @@
|
||||||
|
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] }
|
||||||
|
end
|
||||||
|
assert_equal @site.posts[-1..-9], Jekyll::RelatedPosts.new(@site.posts.last).build
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue