module NavigationHelpers
  def path_to(page_name)
    case page_name

    when 'the homepage'
      root_path

    when /^the ([\w ]+) page$/
      send("#{$1.gsub(/\W+/, '_')}_path")

    else
      raise "Can't find mapping from \"#{page_name}\" to a path."
    end
  end
end

World do |world|
  world.extend NavigationHelpers
  world
end

module NavigationHelpers
  def path_to(page_name)
    case page_name

    when 'the homepage'
      root_path

    when /^the ([\w ]+) page$/
      send("#{$1.gsub(/\W+/, '_')}_path")

    when /^"(\/.*)"/
      $1

    else
      raise "Can't find mapping from \"#{page_name}\" to a path."
    end
  end
end

World do |world|
  world.extend NavigationHelpers
  world
end

Add an arbitrary URL matcher for Cucumber path_to
Add an arbitrary URL matcher for Cucumber path_to
