Good stuff, here are my notes on your code:
-
You are getting this, good work! ๐
-
This test does the job. Be aware though: Rspec comes with built-in expect change test capabilities, which can test if an object changes. (For example, if the length of an array increased by 1.) This will come in handy in the very near future.
-
Note: You caught this error while I was writing this! Nice work! Here is what I wrote anyway:
This is a really tricky one to catch and is a good teaching moment: take a look at this test, which currently passes when it is run. This test is supposed to make sure the
UnderFlow errorin yourQueueclass fires when you try to shift on an array that doesn't contain anything. But take a look at your test: your test is testing to see if aNameErrorfires, not anUnderFlowerror. Do you know why the test still passes? Because aNameErroris firing, because you are calling a method on your queue object that doesn't exist! (YourQueueclass does not have ashiftmethod, it has ashift_first_itemmethod.) Thus, this test is a false positive. Watch out for these! -
The
== trueat the end of this line is not needed, sinceis_full?will return a boolean value. -
Be sure to give your variables meaningful names. For example, instead of calling this variable
@numberperhaps name it something like@maxor@max_allowed, this way it is clear exactly what this variable represents.
Keep at it! Good work so far ๐
-Phil