Sha256: 20173bb6b93255cd42e8f0c14a5b14e7c94eb64b88390348b88c8e19f7b77d96

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 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']
          ]
          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

1 entries across 1 versions & 1 rubygems

Version Path
gollum-descendant_tree-0.0.2 spec/support/test_helpers.rb