-
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
Christina Sherman Api-muncher #25
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
end | ||
end | ||
|
||
describe "show" do |
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.
This describe
should be inside the describe RecipesController do
block
it 'shows a list of recipes' do | ||
VCR.use_cassette('recipes') do | ||
|
||
get recipes_path, params: search |
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.
search
is undefined, maybe this should be something like:
get recipes_path, params: { search: 'pasta' }
|
||
|
||
it "can get the index path" do | ||
ingredients = {ingredients: "chocolate"} |
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.
missing search
key
must_respond_with :ok | ||
end | ||
end | ||
it "will redirect with invalid search terms" do |
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.
This test crashes because of a bug in your index.html.erb
view
if @search_term | ||
@recipes = EdamamApiWrapper.search_recipes(params[:search]) | ||
else | ||
@recipes = nil |
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.
maybe if @search_term
is nil you should make @recipes
be an empty array.
Otherwise your view gives an error when it tries to do .each
on nil
.
<section class="text-center"> | ||
<p class = "btn btn-outline-dark"><%= link_to "View Original Recipe ", "#{recipe.url}", target: :_blank %></p> | ||
</section> | ||
<div class="card-body"> |
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 didn't close this div
end | ||
return @recipe_list | ||
else | ||
return nil |
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.
I suggest returning an empty array if there are no results.
@@ -0,0 +1,53 @@ | |||
require 'httparty' |
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.
Your file should be lowercase.
def self.find_recipe(id) | ||
url = BASE_URL + "search?" + "r=http%3A%2F%2Fwww.edamam.com%2Fontologies%2Fedamam.owl%23recipe_#{id}" + "&app_id=#{ID}&app_key=#{KEY}" | ||
data = HTTParty.get(url) | ||
if data.length |
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.
I would make this if data.length > 0
end | ||
|
||
def show | ||
@recipe = EdamamApiWrapper.find_recipe(recipe.id) |
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.
Shouldn't this be
@recipe = EdamamApiWrapper.find_recipe(params[:id])
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)?