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
Post a Comment