Project Ramon

A learning journey from a Ruby noob perspective

Lunch Panoply: Friday Fixup. An Rspec Rewrite


Hello and happy Friday!

My posts this week have been about me testing out my Adapter class’ behaviors. I have been fortunate to receive some good guidance from both Marek and Ralph on some areas where I wasn’t thinking/implementing my class’ behaviors properly.

Today I think it is necessary to share my rewrite and open myself to more critiques to ensure that the coverage is up to par. So here we go!

Here is my all method’s spec:


I’ve attempted to follow Adam Cuppy’s advice from our pairs and created a fake response, then starting on line: 35, instead of assigning an array to menu_items I assigned the array from my Adapter class’ retrieve method.

Here’s a snippet of the retrieve method:


I’m checking that the retrieve method should expect to receive an array of menu item objects and that these objects are hashes.

Starting on line: 46 I’m expecting a different response than if this request was a success, and am expecting this response to include "{ failure: :error }".

The way I thought about testing the behavior of our menu_items_retriever returning no response objects in the context of an unsuccessful response was to assign the already empty array in the retrieve method and then adding expectations of this array being empty. Is the expectation that this return data be_a_kind_of(Array) unnecessary for this spec? I’ve left it in for now, since I’ve not added this expectation in any of the all method’s specs before it.

And thats all for this method! I’d love to hear if I’m still missing the mark with my tests, so feel free to comment.

Here is a look at my entire test file:

Picks of the Week

I also have a few resources that caught my attention while surfing around the web in an attempt to learn this week.

Here are the code related links:

And some non-technical but insightful links:

I hope you will find these resources as educational as I have.

Have a rejuvenating weekend!


Categories: Newbie, Ruby on rails

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s