Sha256: c2e65d7b036201d1aa6b5b4b1eeb798a1ff872e36c26338f631a1405745addec

Contents?: true

Size: 1.95 KB

Versions: 36

Compression:

Stored size: 1.95 KB

Contents

module NavigationHelpers
  # Maps a name to a path. Used by the
  #
  #   When /^I go to (.+)$/ do |page_name|
  #
  # step definition in web_steps.rb
  #
  def path_to(page_name)
    case page_name

    when /^the (home\s?page|website)/i
      root_path
    when /^the CMS/
      '/admin'
    when /^the (?:root )?content titled "([^\"]*)" page$/i
      node = Node.find_by_title($1)
      node_path(node)
    when /^the content admin page$/
      noodall_admin_nodes_path
    when /^edit the content again$/
      noodall_admin_node_path(@_content)
    when /^the site ?map page$/
      noodall_sitemap_path
    when /^a page that's content is in the "([^\"]*)" template$/
      node = Node.first(:_type => $1.gsub(' ',''), :order => 'created_at DESC')
      node_path(node)
    when /^a page that's content is in the "([^\"]*)" template that does not have published children$/
      node = Factory($1.gsub(' ','_').tableize.singularize, :publish => true)
      node.children.each{|c| c.destroy }
      node_path(node)
    when /^a page that's content is in the "([^\"]*)" template that has published children$/
      node = Factory($1.gsub(' ','_').tableize.singularize, :publish => true)
      3.times do
        Factory(:page_a, :publish => true, :parent => node)
      end
      node_path(node)
    when /^that page$/
      node_path(@_content)
    when /^that page in the CMS$/
      noodall_admin_node_nodes_path(@_content)
    when /^the article list page$/
      node_path(@_content)
    when /content titled "([^\"]*)"$/
      node_path(Node.find_by_title($1))
    when /the site map xml page/
      noodall_sitemap_path(:xml)
    else
      begin
        page_name =~ /the (.*) page/
        path_components = $1.split(/\s+/)
        self.send(path_components.push('path').join('_').to_sym)
      rescue Object => e
        raise "Can't find a mapping from \"#{page_name}\" to a path.\n" +
          "Please add one to #{__FILE__}"
      end
    end
  end
end

World(NavigationHelpers)

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
noodall-ui-0.5.15 features/support/paths.rb
noodall-ui-0.5.14 features/support/paths.rb
noodall-ui-0.5.13 features/support/paths.rb
noodall-ui-0.5.12 features/support/paths.rb
noodall-ui-0.5.11 features/support/paths.rb
noodall-ui-0.4.11 features/support/paths.rb
noodall-ui-0.4.10 features/support/paths.rb
noodall-ui-0.5.10 features/support/paths.rb
noodall-ui-0.5.9 features/support/paths.rb
noodall-ui-0.4.9 features/support/paths.rb
noodall-ui-0.5.8 features/support/paths.rb
noodall-ui-0.4.8 features/support/paths.rb
noodall-ui-0.4.7 features/support/paths.rb
noodall-ui-0.5.7 features/support/paths.rb
noodall-ui-0.5.6 features/support/paths.rb
noodall-ui-0.5.5 features/support/paths.rb
noodall-ui-0.5.4 features/support/paths.rb
noodall-ui-0.5.3 features/support/paths.rb
noodall-ui-0.5.2 features/support/paths.rb
noodall-ui-0.5.1 features/support/paths.rb