Skip to content
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

Jamila Octos c9 #36

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Jamila Octos c9 #36

wants to merge 15 commits into from

Conversation

Jcornick21
Copy link

API Muncher

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
How did you go about exploring the Edamam API, how did you try querying the API? I read through the documentation tried out different queries in postman and looked at the data structure of the response
Describe your API Wrapper. How did you decide on the methods you created? I started with what I needed which was a method to display the initial query and then after quite some time realized that I would need a separate method to do a showpage.
Describe an edge case or failure case test you wrote for your API Wrapper. Not really an edge case just wrote to raise an error if the query is empty.
Explain how VCR aids in testing an API. It makes it so I am not calling to the api every time I run tests that involve the api directly and indirectly(like through routes in the controller)
What is the Heroku URL of your deployed application? didnt deploy
Provide a link to the Trello board you used https://trello.com/b/7GBVLw0L/api-muncher

@Jcornick21
Copy link
Author

I know I didnt get to controller tests and some of my other tests have probably broken due to adding the show page functionality. I also needed and wanted to add a test to the wrapper tests for the new method I created. I meant to at least put some flex css for the pagination and make my form view into a partial so I could better place it when I added more css later.

@droberts-sea
Copy link

API Muncher

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Rails fundamentals (RESTful routing, use of named paths) yes
Semantic HTML yes
Errors are reported to the user no - when I mangle the recipe URI, I get an exception rather than a polite error message
API Wrapper to handle the API requests yes
Controller testing no
Lib testing yes - a couple are missing but in general this looks very good
Search Functionality yes
List Functionality yes
Show individual item functionality (link to original recipe opens in new tab) yes
Styling
Responsive layout yes
List View shows 10 items at a time/pagination yes
The app is styled to create an attractive user interface no
API Features
The App attributes Edaman no - This is really important! When you're designing code for money, using someone else's work without attribution is a good way to end up in legal trouble.
The VCR casettes do not contain the API key yes
External Resources
Link to Trello Board yes
Link to deployed app on Heroku no
Overall

Good work overall. It's clear that the the core learning goal for the assignment around interacting with an API was met. I also really like your lib tests - good job on this!

There are two places I see room for improvement. The first is in error handling - making sure that you've got a comprehensive story for how errors get from the bottom layer (the API) all the way back to the user is not easy, but it's a piece of what sets apart a really strong application. The other place is controller testing, which you're aware of. Fortunately these are both major components of the VideoStore API project - please spend some time focusing on these concepts this week.

I've seen you putting in a large amount of work recently, and I think it really shows on this assignment. This submission represents a big improvement over where you were a couple weeks ago. Keep it up!

root 'edamams#new'
get '/recipe/new', to: 'edamams#new'
get '/recipe/index', to: 'edamams#index', as: 'recipe_list'
get '/recipe/:uri', to: 'edamams#show', as: 'recipe_details'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that new is a good name for this route/action. You're not really creating a new recipe, you're doing a search.

Also, could you use resources for the index and show pages?

raise_error(source)
raise_error(uri)
raise_error(url)
raise_error(ingredientLines)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say you're over-validating here. In general you should only validate fields that will cause your app to break if they're not there. In this case that's label, uri and possibly image. Anything beyond that is an unnecessary dependency on the data coming from the API, and is an extra thing for you to test.

def self.raise_on_error(response)
# this needs to be changed based on the api
unless response["more"]
raise RecipeError.new(response["error"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that Edamam gives error messages back under the error key like this.

full_uri = URI.encode("https://api.edamam.com/search?r=#{BASE_URI}#{uri}&app_id=#{TOKEN_ID}&app_key=#{TOKEN_KEY}")

response = HTTParty.get(full_uri).parsed_response
return Recipe.from_api(response[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check that the API call succeeded before calling Recipe.from_api here.

def index
recipe_list = RecipeApiWrapper.recipes(params[:recipe])
@recipe_list = Kaminari.paginate_array(recipe_list).page(params[:page]).per(10)
end

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 "raises and error if query is empty" do
VCR.use_cassette('recipes') do
query = ' '

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good error case

describe "single recipe" do
it "" do

end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two tests I would want to see here:

  • Do you get an instance of class Recipe back with a valid URI?
  • What happens when you pass in a bogus URI?


describe EdamamsController do
# it "must be a real test" do
# flunk "Need real tests"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need some controller tests! Here is my list of what I'm looking for:

Index:

  • Valid search term
  • Search term that produces no results (e.g. adfohdaglhjalj)
  • No search term

Show:

  • Valid URI
  • Bogus URI
  • No URI

Root

  • Does it work at all (only one test)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants