What I hate most about being a newbie... 11/01/2011
Sure, we all have to learn something new at some point. But what I hate the most is the solution that you can't learn from. So, I spent yesterday working on Chapter 11 of the Rails Tutorial. It's been great, but there was a "re-factoring" section in the middle that I knew was going to haunt me. There were too many changes, too many RSpec test added and and the development was just too much. My code "blew up" on me. I had at least 14 tests go red, and the solution that should have been obvious was completely hidden behind all my attempted fixes that only made things worse. So, I blew away all my Chapter 11 work ("git reset --hard" takes you back to your last commit). I started again, and when I got to the "too busy" part, I broke it down into smaller chunks and went by baby steps (with a complete RSpec run after every step). Did I find my problem? NO!!!!! Every RSpec test passes now with flying colours. The big step (I had thought) was to move "def authenticate ..." from the users_controller to the sessions_helper. I moved the code, ran the test, held my breath, ... and it ran green! For once, I really wanted my code to blow up (so it would justify all my pain from yesterday). What I had spent an hour researching and 2 hours repairing... was not a problem ... at all. (groan) So, I have no idea where my code went wrong yesterday, so I have nothing to learn from my mistake. However, maybe my biggest mistake was to "follow the instructions" when my gut said, "Take it slow or you'll get lost!" So, that's the lesson of the day. Take your TDD in baby steps (and don't worry if it feels slow, because the alternative is ... ARGGG!) [TDD = Test Driven Development] Add Comment What is happening when your code runs fine, the tutorial shows that your code should be "RSpec green", but it isn't? For me, it's time to go to StackOverflow.com again. The hardest part was searching for the right answer. But once it was found, it just works! So, for those of you stuck in (Michael Hartl's awesome Rails Tutorial) chapter 10 and wondering why you now have RSpec giving you 7-10 errors, don't worry! I had suspected all along that this was just one of the differences between Rails 3.0 and Rails 3.1, and it appears that I was right! When searching for "test_sign_in" the 4th hit took me here, and the answer redirected me here, where I received the bizarre but efficient changes that needed to be made. In sessions_helper, find def sign_in
[TDD = Test Driven Development] |

RSS Feed