-
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
Brandy Austin - API Muncher - Octos #42
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
|
||
get '/recipes', to: 'recipes#index', as: :index | ||
get '/search', to: 'recipes#search', as: :search | ||
|
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.
Why not use resources
for line 8?
recipe = MuncherApiWrapper.show_recipe(id) | ||
|
||
if recipe.nil? | ||
flash[:notice] = "Something went wrong. Please enter a new search." |
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 where using an exception to report errors comes in handy - an exception contains a lot more useful info than a nil
.
# #recipe_ always has to be last # delimited item in uri otherwise this breaks | ||
label_uri_image[:id] = r["recipe"]["uri"].split("#recipe_")[-1] | ||
label_uri_image[:image] = r["recipe"]["image"] | ||
|
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 sorting out the recipe URI!
label_uri_image = {} | ||
label_uri_image[:label] = r["recipe"]["label"] | ||
# #recipe_ always has to be last # delimited item in uri otherwise this breaks | ||
label_uri_image[:id] = r["recipe"]["uri"].split("#recipe_")[-1] |
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 be creating an instance of your Recipe
class here. That would let the controller / views treat this like any other model, and isolate the knowledge of how the API sends data back in one place.
it "can't get the recipe's info and redirects with invalid id" do | ||
VCR.use_cassette("chicken") do | ||
recipe_list = MuncherApiWrapper.list_recipes("chicken") | ||
id = recipe_list.first[:id] + "abc" |
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 nailing this error case. 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?
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions