Debugging Exercise RSPEC Errors


I’m having some problems running the specs for the debugging exercises from the RSPEC module of the Alpha Course. I’ve included a screen shot of my terminal window showing the error messages. Any help on this would be greatly appreciated.


The code isn’t running…there’s clearly something wrong, but Ruby tells you what it is. The first line of the error says:

rb:15: syntax error, unexpected keyword_else, expecting ‘)’

This is a wealth of information:

  • On line 15 of your code there is a syntax error.
  • Ruby wasn’t expecting to see the word ‘else’ and was expecting a closing parentheses instead.

Start by taking a look around line 15 and check to see if there is anything wrong with the word ‘else’, or if there should be a closing parentheses somewhere in the vicinity. You’ll find the bug in no time. And remember, the first rule of debugging is to always read the error message. It’s there to help you!

I’m trying to determine whether or not this result is typical after entering ‘bundle exec rspec’ for the debugging exercises specifically. The reason is I’m unsure is because the previous module’s exercises (Control Flow) produced a result that displayed the name of defined methods, cleared specs in green, total runtime, examples, and failures (see screenshot below).

Is the goal to fix the code within the ruby file to run like the Control Flow ruby file when entering ‘bundle exec rspec’ into terminal, or is there something wrong with the way I set up my environment? Hope my questions make sense!

You should generally expect a similar result to the one you got with Control Flow. The reason the result you posted looks different is because there is a bug that prevents the code from running. Since the code can’t run, it can’t show you which specs were passed or failed. It’s your job to find and fix the bugs so that you get a result like you did with Control Flow.

Thanks numie2. Makes a lot more sense after isolating parts of the code that produced the errors by commenting out. Will need to brush up more on debugging to fix it quicker the next time through.