Open
Conversation
API MuncherWhat We're Looking For
|
dHelmgren
reviewed
Nov 14, 2018
| root 'recipe#home' | ||
|
|
||
| get '/recipes', to: 'recipe#index', as: 'recipes' | ||
| get '/recipe/:uri', to: 'recipe#show', as: 'recipe' |
There was a problem hiding this comment.
Could you use resources for the index and show pages?
| ) | ||
| end | ||
|
|
||
| def self.keyboard(api_params) |
There was a problem hiding this comment.
The keyboard method here seems like the thing you want to call when you do create_recipe as well. This code isn't very DRY.
|
|
||
| def show | ||
| uri = params[:uri] | ||
| @recipe = EdamamApiWrapper.find_a_recipe(uri).first #takes the object out [] |
There was a problem hiding this comment.
You've written your API wrapper to raise an error if the API call fails, but you're not looking for an error here. You should wrap this call in a begin/rescue.
| it "should get index" do | ||
| VCR.use_cassette('search_file') do | ||
| get recipes_path | ||
| must_respond_with :success |
There was a problem hiding this comment.
There are some interesting cases you're not covering here:
- What happens if no search term is provided?
- What if the search returns no results?
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?
|
|
||
| it 'can list recipes' do | ||
| VCR.use_cassette('seach_file') do #ensure code inside block will use cassette | ||
| hits = EdamamApiWrapper.search('food') |
There was a problem hiding this comment.
What if the search term has no results?
| it 'can show a recipe'do | ||
| VCR.use_cassette('find_a_recipe') do | ||
| apple_pie = EdamamApiWrapper.find_a_recipe('pie') | ||
|
|
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
lib? How would your project change if you needed to interact with more than one API (aka more than just the Edamam API)?Describe your API wrapper, the methods you created in it, and why you decided to create those methods/how they were helpful | I created 2 methods that list recipes and shows a recipe. I created 2 more methods ".create_recipe" and "self.keyboard" that creates a recipes and a recipe.
What was an edge case or failure case test you wrote for your API Wrapper? What was a nominal case? | I did not test edge or failure cases just nominal cases "it can list recipes' and "it can show a recipe"
How does VCR aid in testing an API? | It prevents you from calling the API by recording HTTP interactions and replay them .
What is the Heroku URL of your deployed application? | https://ada-muncher-2018.herokuapp.com/