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

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -