-
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
Karinna Iniguez - API Muncher - Octos #22
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
|
||
root 'recipes#search' | ||
get 'recipes', to: 'recipes#index', as: 'results' | ||
get 'recipe/: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 the index and show pages?
@@ -0,0 +1,25 @@ | |||
<header> | |||
<%= render partial: 'search_form' %> | |||
</header> |
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.
Since you include the search form on every page, it might make sense to put it in application.html.erb
.
|
||
<section class="search-form"> | ||
<h1><%= link_to "YUMMMMSTER", root_path %></h1> | ||
<%= form_tag results_path, method: :get do %> |
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 use of a view partial to DRY this up.
recipe = Recipe.new(response[0]) | ||
return recipe | ||
else | ||
|
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 probably have something in this else
clause - return nil
or throw an exception.
|
||
def show | ||
@recipe = EdamamApiWrapper.single_search(params[:id]) | ||
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.
What if the search fails? Your page should probably report the failure to the user.
it "responds with success for search with no results" do | ||
VCR.use_cassette("recipes") do | ||
query = "something that doesnt exist" | ||
get results_path, params: {query: query} |
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 job catching this error case!
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?
describe "show" do | ||
it "responds with success" do | ||
VCR.use_cassette("recipes") do | ||
id = "67b2867627c159e4f5bbaf2431b3ccb6" |
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.
What if you give it a bogus URI?
it "returns single recipe if searching single" do | ||
VCR.use_cassette("recipes") do | ||
id = "67b2867627c159e4f5bbaf2431b3ccb6" | ||
response = EdamamApiWrapper.single_search(id) |
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.
What happens for an invalid ID?
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions