Open
Conversation
…es controller, and created index and show views
API MuncherWhat We're Looking For
|
droberts-sea
reviewed
May 9, 2018
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
| root 'recipes#search' | ||
| get '/results', to: 'recipes#index', as: 'results' | ||
| get '/recipes/:id', to: 'recipes#show', as: 'recipe' |
| def catch_api_error | ||
| begin | ||
| yield | ||
| rescue EdamamApiWrapper::EdamamError |
There was a problem hiding this comment.
Good work matching your error handling here to what's going on in the API wrapper.
| APP_ID = ENV["EDAMAM_APP_ID"] | ||
| APP_KEY = ENV["EDAMAM_APP_KEY"] | ||
| BASE_URL = "https://api.edamam.com/search?" | ||
| BASE_URI = "http://www.edamam.com/ontologies/edamam.owl#recipe_" |
There was a problem hiding this comment.
The variable names BASE_URL and BASE_URI are very similar - I would be worried about typoing one for the other. Could you choose something more visually distinct (maybe BASE_RECIPE_ID)?
|
|
||
| unless response["count"] > 0 | ||
| raise EdamamError.new | ||
| end |
There was a problem hiding this comment.
You should include an error message here, so that if some other developer (or future you) encounters this error they know what went wrong.
| describe "index" do | ||
| it "succeeds for a valid search query" do | ||
| VCR.use_cassette('recipes') do | ||
| get results_path, params: { query: "chicken"} |
There was a problem hiding this comment.
It might also be worthwhile to add some tests around the paging parameters:
- What happens if they're absent?
- Do you get different results when they change?
- What if you send a bogus value, like a negative page number?
|
Also, I love your site name. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions