Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

BJHunnicutt
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a 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)

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

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)

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

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)

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants