I am running an RSpec test on a model and getting errors for string methods such as: “index, “downcase,” and “strip.” Any ideas why that is and how I can fix it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are getting “undefined method”, then the object you are operating on is likely not a string. Try printing out the result from
.classbefore calling.strip, etc and see what type of object you are working with. A function that normally returns a string might return a non-string (likenil) on error, and you may be operating on something like that inadvertently.