diff --git a/lib/docs/core/filter.rb b/lib/docs/core/filter.rb index 031c25eb..0209d7b2 100644 --- a/lib/docs/core/filter.rb +++ b/lib/docs/core/filter.rb @@ -50,6 +50,10 @@ module Docs subpath.blank? || subpath == '/' || subpath == root_path end + def initial_page? + root_page? || context[:initial_paths].include?(subpath) + end + SCHEME_RGX = /\A[^:\/?#]+:/ def fragment_url_string?(str) diff --git a/test/lib/docs/core/filter_test.rb b/test/lib/docs/core/filter_test.rb index 107627ef..d98ecdad 100644 --- a/test/lib/docs/core/filter_test.rb +++ b/test/lib/docs/core/filter_test.rb @@ -78,6 +78,27 @@ class DocsFilterTest < MiniTest::Spec end end + describe "#initial_page?" do + before do + context[:initial_paths] = ['initial'] + stub(filter).root_page? { false } + end + + it "returns true when #root_page? is true" do + stub(filter).root_page? { true } + assert filter.initial_page? + end + + it "returns true when #subpath is included in :initial_paths" do + stub(filter).subpath { 'initial' } + assert filter.initial_page? + end + + it "returns false otherwise" do + refute filter.initial_page? + end + end + describe "#fragment_url_string?" do it "returns false with ''" do refute filter.fragment_url_string?('')