Sha256: 63826c722d594a1053faa81bd6c61332a632d1566f92c29c91c1fa274557fa87

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module NavigationHelpers
  # Maps a name to a path. Used by the
  #
  #   When /^I go to (.+)$/ do |page_name|
  #
  # step definition in webrat_steps.rb
  #
  def path_to(page_name, routing=nil)
    case page_name
    
    when /the homepage/
      '/'
    
    # Add more mappings here.
    # Here is a more fancy example:
    #
    #   when /^(.*)'s profile page$/i
    #     user_profile_path(User.find_by_login($1))
    # added by script/generate pickle path
    when /the newsletter archive page/
      "/newsletters/archive"
    when /newsletter named "([^"]+)"'s new piece page$/
      newsletter_name = $1
      newsletter = Newsletter::Newsletter.where(name: newsletter_name).first
      "/newsletter/newsletters/#{newsletter.id}/pieces/new"

    when /^the (.+?) page$/                                         # translate to named route
      routing.send("#{$1.downcase.gsub(' ','_')}_path")
    else
      raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
        "Now, go and add a mapping in #{__FILE__}"
    end
  end
end

World(NavigationHelpers)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
newsletter-3.2.25.1 spec/test_app/features/support/paths.rb
newsletter-3.2.22.0 spec/test_app/features/support/paths.rb
newsletter-3.2.7 spec/test_app/features/support/paths.rb
newsletter-3.2.6 spec/test_app/features/support/paths.rb
newsletter-3.2.5 spec/test_app/features/support/paths.rb
newsletter-3.2.4 spec/test_app/features/support/paths.rb
newsletter-3.2.2 spec/test_app/features/support/paths.rb
newsletter-3.2.1 spec/test_app/features/support/paths.rb
newsletter-3.2.0 spec/test_app/features/support/paths.rb