3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/generators/katapult/basics/templates/features/support/paths.rb', line 3
def path_to(page_name)
case page_name
when 'the homepage'
root_path
when /^the list of (.*?)$/
models_prose = $1
route = "#{model_prose_to_route_segment(models_prose)}_path"
send(route)
when /^the (page|form) for the (.*?) above$/
action_prose, model_prose = $1, $2
route = "#{action_prose == 'form' ? 'edit_' : ''}#{model_prose_to_route_segment(model_prose)}_path"
model = model_prose_to_class(model_prose)
send(route, model.reorder(:id).last!)
when /^the (page|form) for the (.*?) "(.*?)"$/
action_prose, model_prose, identifier = $1, $2, $3
path_to_show_or_edit(action_prose, model_prose, identifier)
when /^the (.*?) (page|form) for "(.*?)"$/
model_prose, action_prose, identifier = $1, $2, $3
path_to_show_or_edit(action_prose, model_prose, identifier)
when /^the (.*?) form$/
model_prose = $1
route = "new_#{model_prose_to_route_segment(model_prose)}_path"
send(route)
when /"(.+?)"$/
$1
end
end
|