Karinna Iniguez - API Muncher - Octos#22
Karinna Iniguez - API Muncher - Octos#22karinnainiguez wants to merge 24 commits intoAda-C9:masterfrom
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.
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.
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.
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.
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.
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.
Good job catching this error case!
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?
| describe "show" do | ||
| it "responds with success" do | ||
| VCR.use_cassette("recipes") do | ||
| id = "67b2867627c159e4f5bbaf2431b3ccb6" |
| it "returns single recipe if searching single" do | ||
| VCR.use_cassette("recipes") do | ||
| id = "67b2867627c159e4f5bbaf2431b3ccb6" | ||
| response = EdamamApiWrapper.single_search(id) |
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions