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

API-muncher Brennan Octos #40

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

Conversation

MississippiBrenn
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 copied from the version in the slackapi project, then changed things as needed.
Describe your API Wrapper. How did you decide on the methods you created? I created the least amount of
Describe an edge case or failure case test you wrote for your API Wrapper. Only works with one parameter
Explain how VCR aids in testing an API. It takes in the test data from the api and runs tests against that.
What is the Heroku URL of your deployed application? https://edamam-cbrenn.herokuapp.com/
Provide a link to the Trello board you used https://trello.com/b/y2f3P628/edamam

@droberts-sea
Copy link

API Muncher

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene I would like to see more frequent commits with more descriptive commit messages. If this is something you struggle with, this article might be interesting to you.
Comprehension questions These are incomplete!
General
Rails fundamentals (RESTful routing, use of named paths) yes
Semantic HTML seems like your views are a little confused - see inline
Errors are reported to the user no - When I mangled the recipe URI, I got an exception instead of a polite error message
API Wrapper to handle the API requests yes
Controller testing no
Lib testing no
Search Functionality yes
List Functionality yes
Show individual item functionality (link to original recipe opens in new tab) yes
Styling
Responsive layout no
List View shows 10 items at a time/pagination no
The app is styled to create an attractive user interface no
API Features
The App attributes Edaman yes
The VCR casettes do not contain the API key yes
External Resources
Link to Trello Board yes
Link to deployed app on Heroku Gives me an application error - did you set up your API keys?
Overall

This submission is concerning to me. You were able to get the core API functionality working, which is a good start. However there are many important pieces that are missing or broken, including error handling, testing, styling, git hygiene and deployment. Remembering how to write "regular" Ruby code is part of the challenge of this assignment, but it seems like you're still struggling with Rails and Ruby fundamentals.

Many of the problems I'm seeing are things that will hamper the rest of your development process. For example, having a good story around error handling makes everything else easier, because when something goes wrong you get a clear reason why instead of having to hunt for it.

When you meet with Charles this week, it would be worthwhile to go over some of these pieces, particularly error handling and testing. Aside from being important on their own, having these locked in a little better will help when we switch to JavaScript next week too.

def index
if params[:search]

#returns all recipes for GET request from API

Choose a reason for hiding this comment

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

I like the idea of using the same action/view for the homepage and search results.


<h1>Search recipes for </h1>

<%= form_tag(root_path, method: 'get') do %>

Choose a reason for hiding this comment

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

You should put these in some sort of sectioning element - maybe a <header>?

<% end %>

<%= yield %>
</body>

Choose a reason for hiding this comment

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

You should always put the yield inside a <main> tag, since it's where the main content of your page will appear. Doing this will make debugging easier, since when you inspect the page it'll be clear whether content came from the layout or the view template.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

Choose a reason for hiding this comment

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

You shouldn't be putting a full HTML document into your view templates, since they'll be inserted inside of views/layouts/application.html.erb

<main>
<% @recipes.each do |recipe|%>
<secton class = "recipe section">
<%= image_tag(recipe.image, alt: "picture of the image") %>

Choose a reason for hiding this comment

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

This is good semantic HTML.

def catch_api_error
begin

yield

Choose a reason for hiding this comment

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

You've copy-pasted this method here from the lecture notes, but you've commented out the around_action above, and the error you're looking for doesn't match what your API wrapper is producing. It would be worth spending some time studying this to understand how it is supposed to fit together.

url = url_root + uri + "&app_id=#{APP_ID}" + "&app_key=#{APP_KEY}"

response = HTTParty.get(url).parsed_response

Choose a reason for hiding this comment

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

You should be checking the response for errors here.

# This is a factory method! It reads the data
# we got back from the API, and turns it into
# an instance of Channel by calling self.new

Choose a reason for hiding this comment

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

What is a factory method?

it "can get the index path" do
get root_path

must_respond_with :ok

Choose a reason for hiding this comment

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

You need a lot more in the way of controller tests. At the very least you need the following:

Index:

  • A good search result is provided
  • A search result is provided but produces no results

Show:

  • A good recipe URI is provided
  • A bad recipe URI is provided

You should also be wrapping these tests in VCR, since the controller make API calls via the API wrapper.

it 'can create an instance of itself' do
a = EdamamApiWrapper.new
a.wont_be_nil
end

Choose a reason for hiding this comment

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

Your application doesn't ever call new on EdamamApiWrapper - it only has self methods and isn't meant to be instantiated. Why are you testing this functionality?

Choose a reason for hiding this comment

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

Here is my list of test cases I'd look for in this file:

  • Call list_recipes with a good search term, get back a list of Recipe objects
  • Call list_recipes with a bogus search term like adlsfjaog, get back an empty array or an error
  • Call show_recipe with a good URL, get back a Recipe object
  • Call show_recipe with a bogus URL, get back an error or nil

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