-
Notifications
You must be signed in to change notification settings - Fork 47
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
Shelan's API Muncher #43
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
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.
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?
) | ||
end | ||
|
||
def self.keyboard(api_params) |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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') | ||
|
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 recipe doesn't exist?
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/