Sha256: a531fb42e7b56792ef8912c8ec84ea9873d081d49cf021f5cda292622ac17313

Contents?: true

Size: 1.63 KB

Versions: 5

Compression:

Stored size: 1.63 KB

Contents

module Gollum
  module DescendantTree
    module TestHelpers
      module PageMockFactory
        def build_mock_pages
          pages_info = [
            ['home', 'home.md', 'Home'],
            ['home/current_page', 'current_page.md', 'Current Page'],
            ['home/current_page/child','child.md','Child'],
            ['home/current_page/child/grandchild','grandchild.md','Grandchild'],
            ['home/current_page/child/grandchild/greatgrandchild','greatgrandchild.md','GreatGrandchild'],
            ['home/current_page/child_sibling', 'childsibling.md', 'Child Sibling'],
            ['home/sibling/current_page', 'current_page.md', 'Sibling']
          ]
          pages = []
          pages_info.each do |page|
            pages << create_page(page)
          end
          pages
        end

        def create_page(page_config)
          page = double
          page.stub(:url_path).and_return(page_config[0])
          page.stub(:filename).and_return(page_config[1])
          page.stub(:title).and_return(page_config[2])
          page
        end

        def tree_with_correct_nesting
          [
            {:title=>"Current Page", :url_path=>"home/current_page", :nest_index=>0},
            {:title=>"Child", :url_path=>"home/current_page/child", :nest_index=>1},
            {:title=>"Grandchild", :url_path=>"home/current_page/child/grandchild", :nest_index=>2},
            {:title=>"GreatGrandchild",:url_path=>"home/current_page/child/grandchild/greatgrandchild", :nest_index=>3},
            {:title=>"Child Sibling", :url_path=>"home/current_page/child_sibling", :nest_index=>1}
          ]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gollum-descendant_tree-0.0.8 spec/support/test_helpers.rb
gollum-descendant_tree-0.0.7 spec/support/test_helpers.rb
gollum-descendant_tree-0.0.6 spec/support/test_helpers.rb
gollum-descendant_tree-0.0.5 spec/support/test_helpers.rb
gollum-descendant_tree-0.0.4 spec/support/test_helpers.rb