Sha256: 10b93927a6cfd3ad884af1139a5b0aaa83cc1f9ca94e1e448a96fcf25291069d

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 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, format=nil)
    case normalize_page_name(page_name)
    when /^\/(.*)/
      $1
    when /the home\s?page/
      '/'
    when /the (\S+) (|admin )page as (\w+)/
      path_to($1, $3)
    when /the (\S+) ($:|admin )page/
      path_to($1)
    when /first/
      '/first'
    when /new child/
      '/my-child'
    when /great-grandchild/
      '/parent/child/grandchild/great-grandchild'
    when /sitemap/i
      admin_pages_path(:format => format)
    when /login/i
      login_path(:format => format)
    when /preferences/i
      admin_preferences_path(:format => format)
    when /snippets/i
      admin_snippets_path(:format => format)
    when /login/i
      login_path(:format => format)
    when /users/i
      admin_users_path(:format => format)
    when /pages/i
      admin_pages_path(:format => format)
    when /layouts/i
      admin_layouts_path(:format => format)
    when /snippets/i
      admin_snippets_path(:format => format)
    when /users/i
      admin_users_path(:format => format)
    when /configuration/i
      admin_configuration_path(:format => format)
    when /extensions/i
      admin_extensions_path(:format => format)
    when /export/i
      export_path(:format => format)
    else
      raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
        "Now, go and add a mapping in #{__FILE__}"
    end
  end
  
  def normalize_page_name(page_name)
    page_name.gsub(/^["']+(.*?)["']+$/,'\1')
  end
end

World(NavigationHelpers)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
radiant-1.0.0.rc1 features/support/paths.rb
radiantcms-couchrest_model-0.1.3 features/support/paths.rb
radiantcms-couchrest_model-0.1.2 features/support/paths.rb
radiantcms-couchrest_model-0.1.1 features/support/paths.rb
radiantcms-couchrest_model-0.1 features/support/paths.rb