Pipes - Kimberley Zell - Api-Muncher#38
Conversation
…al_nutrients an array of only the key value pairs I want on my show page.
…empt to figure out how to add Foundation to my project.
…changed the image to use the url
…recompile to see if that helps
API MuncherWhat We're Looking For
|
| </header> | ||
|
|
||
| <section class="main"> | ||
| <% if flash[:message] %> |
There was a problem hiding this comment.
Why <section class="main"> instead of <main>?
| response = self.parse_response(HTTParty.get(url)) | ||
| recipe_list = [] | ||
|
|
||
| if response.is_a?(Hash) && response["hits"] |
There was a problem hiding this comment.
I like these checks - they'll definitely keep your program form trying to read data that doesn't exist.
One thing I'm noticing: this method doesn't have any way to distinguish between an error response (for example because of bad API keys) and a success response with no hits.
Since one of these cases is a programer error and the other indicates the user did something wrong, I would argue that they ought to be handled differently. In order to do so, this method would have to return some more information.
| end | ||
|
|
||
| it "returns a collection of recipes when from parameter is not given" do | ||
| VCR.use_cassette("recipes") do |
There was a problem hiding this comment.
I like that you exercise both these cases around the from parameter. Other cases I'd be interested in seeing here:
- What if the search returns no results (for example, a search for "dfaljdfalflaksjflaksj")?
- What if the paging parameters are invalid (negative number, etc)?
- What if the paging parameters take you past the end of the available search results?
The first of those is covered by your lib tests below, but it's still important to verify the controller does the right thing in this situation.
|
|
||
| it "returns not found when an invalid uri is given" do | ||
| VCR.use_cassette("bad_uri_recipe") do | ||
| get recipes_path, params: { id: "http://www.edamam.com/ontologies/edamam.owl#recipe_421df807e21c65c842ec62870604" } #bad uri |
| end | ||
|
|
||
| VCR.use_cassette("recipe") do | ||
| recipe = RecipeApiWrapper.find(uri) |
There was a problem hiding this comment.
I like the pattern of this test - using real search results to seed the call to find.
| result.must_be_kind_of Array | ||
| result.must_be_empty | ||
| end | ||
| end |
There was a problem hiding this comment.
I would like to see some testing around the second parameter to search here.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions