Copy Paste Error with Rspec

software ruby on rails

Everyone loves laughing with others about their mistakes. Let’s laugh at me for a second here.

I test my Rails applications with RSpec. While editing the users factory for 2 new user types, I copied lines 19-23 in the image below. I changed the factory name to the 2 added user types, saved and closed the file. I then proceeded to update the users controller spec to test the permissions of these two new user types. Between not being confident in my RSpec skills and getting some false positives, I couldn’t figure out why some tests passed and some failed. After way too long, I finally found the problem. Can you?

Copy/Paste normally saves time but in this case it definitely didn’t. Always double check your code, friends. 🤦‍♂️

Chris Francis
Software Developer, BiteSite