The Roadblock
Day 6 started off alright. I picked up where I had left off on Friday, looking to finish Chapter 9 of the Ruby Mastery quiz and move on to the tenth and final chapter. I finished my program, ran it a few times to see if it worked with all eventualities and was satisfied it did. So I ran RSpec to test it against the spec files. About 16 errors came back to me. No big deal I thought, I have fixed errors in the last 8 chapters, I can fix these too. A couple of them were easy fixes, a loop not breaking properly, spaces in the wrong place, but there was a group of errors that I just couldn’t fix.
I looked into the spec file to see what it expected of me. The problem was the way it tested to see if a number string converted into the right integer. It was injecting an array into the method, whereas I had been using just strings looked up from a hash. “Ok, I can change that” I thought. But no matter what I did I could not get it to work. I was getting NoMethodError’s every time. Trying to get my code to work and the test code to work together was proving impossible.
Looking back at it now, I can see I was an idiot, for many reasons:
1. I should have checked the spec file first, to see what it expected, and to make sure my code would work in a similar way.
2. I was trying to adjust my code so that it would pass the test, rather than understanding what I had done wrong. The more frustrated I got the more I tried to just cheat the code into working.
3. I wasted a whole day trying to fix it. One of the first things the coaches told us was ‘code is cheap’. But I didn’t want to delete all my code and start again, it was working as it should, just not passing the test, surely I wouldn’t have to delete it all.
I went home that day defeated, the tests still wouldn’t pass and I had tried everything I could think of to fix it. As sad as it is, it actually kept me awake that night, I kept thinking about the code and why it wasn’t working, it annoyed me that much.
I decided that night, I am starting again tomorrow.
