ruby on rails - DRYing out the path.rb -
i'm new cucumber, , i'd ask how dry out code (which not contain errors):
when /^the user page$/ users_path when /^the review page$/ reviews_path
i tried use regexp like
when /^the (.+) page$/ $1.to_s+'s_path'
but apparently wrong. in advance!
solution (based on answer aledalgrande):
when /^the (.+) page$/ send("#{$1}s_path")
this should work:
when /^the "(.+)" page$/ |destination| send("#{destination}s_path") end
Comments
Post a Comment