Setting a dynamic variable name that receives an argument in ruby capybara -


i trying set variable name based on value passed user

my capybara step looks this:

when(/^i have value save user [0-9]$/) |number|   @user_value_#{number} = another_variable end 

this doesn't seem work.

is there way this?

you need use object#instance_variable_set, so

instance_variable_set(“@user_value_#{number}”, another_variable) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -