-
Notifications
You must be signed in to change notification settings - Fork 44
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
Caroline Nardi - API Muncher - Octos #29
base: master
Are you sure you want to change the base?
Conversation
…es controller, and created index and show views
API MuncherWhat We're Looking For
|
# 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' |
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.
Could you use resources
for this?
def catch_api_error | ||
begin | ||
yield | ||
rescue EdamamApiWrapper::EdamamError |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions