-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maddie Shields - Edges - API Muncher #48
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
Good work overall! The core functionality of this app works well, and it's clear to me that the learning goals of this assignment were met. Most of the things that aren't quite there (styling, deployment) feel to me like issues of not enough time rather than not understanding. The one exception to this is error handling - make sure to pay close attention to this on future projects. Handling errors gracefully doesn't just help your users, it makes your life easier as well since you get clear info about why things aren't working. This will be especially important in JavaScript. I've left a number of comments inline, but in general I am pretty happy with what I see here. Keep up the hard work! |
recipe_uri_list << recipe.uri | ||
end | ||
|
||
if !recipe_uri_list.include?(uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever - I like the idea of not doing another search if the query is in the most recent results, and I'm glad that you figured out how to make it work if the query is not.
We could probably clean this up a little though:
def self.show_recipe(uri)
# Check the most recent search results
@recipe_list.each do |recipe|
if recipe.uri == uri
return recipe
end
end
# Didn't find it, so make a new query
recipe_uri_list = []
# copy-paste lines 35-38, then end the method
end
|
||
response = HTTParty.get(encoded_uri) | ||
return Recipe.new(response[0]) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the API call didn't return any results?
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to include this HTML boilerplate in your view templates, it should be handled by layouts/application.html.erb
.
it "should redirect to root with invalid id" do | ||
VCR.use_cassette("show") do | ||
|
||
get recipe_path ("000") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that you're testing this error case, but I don't think your application actually handles this situation.
describe "show_recipe" do | ||
it "can show a single recipe" do | ||
response = EdamamApiWrapper.search("chicken") | ||
recipe_uri = "7bf4a371c6884d809682a72808da7dc2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the recipe ID is invalid?
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions
lib
? How would your project change if you needed to interact with more than one API (aka more than just the Edamam API)?