-
Notifications
You must be signed in to change notification settings - Fork 48
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
Jeannie's API muncher #86
base: master
Are you sure you want to change the base?
Conversation
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.
@BJHunnicutt Nice work on this project. Very cleanly written and it executes well. I left a few notes in your code, but overall, very impressive.
@nutrition_info = @recipe.nutrition_info | ||
end | ||
|
||
def get_total(recipes) |
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.
get_total
should be private if it's an internal helper method.
end | ||
return recipes | ||
else | ||
return nil |
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.
Good handling of getting an unexpected response.
|
||
url = BASE_URL + "search?app_id=#{EDAMAM_ID}" + "&app_key=#{EDAMAM_KEY}" + "&q=#{search_term}" | ||
|
||
data = HTTParty.get(url) |
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.
Just to confirm when you use this you'll end up making 2 API calls, that is a bit of a performance penalty. You might think down-the-road about what you could do to optimize the app.
|
||
if name == nil || id == nil || name == "" || id == "" | ||
raise ArgumentError | ||
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.
Good work requiring necessary fields.
assert_equal @controller.params[:to], 24 | ||
assert_not_equal @controller.instance_variable_get(:@total), 14 #14 is what the api says it is | ||
assert_equal @controller.instance_variable_get(:@total), 12 #12 is what the number of actual recipes returned (only knows this when the last set of recepes is delivered) | ||
|
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.
Good work using ap
to figure out what you can do to test the instance variables.
end | ||
end | ||
|
||
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.
You should also probably test the negative case and make sure that you handle cases where the search request or the show page is invalid.
No description provided.