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

Pipes - Sairagul - Muncher #48

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Controller tests for index and results pages pass
sairagula committed Nov 10, 2017
commit 07572dad325b580329a0fc897ced0042425a91a4
134 changes: 134 additions & 0 deletions test/cassettes/.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
http_interactions:
- request:
method: get
uri: https://api.edamam.com/search?app_id=<APP_ID>&app_key=<API_KEY>&from=0&q=qqqqqqq&to=10
body:
encoding: US-ASCII
string: ''
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 200
message: OK
headers:
Server:
- ngx_openresty
Date:
- Fri, 10 Nov 2017 07:42:58 GMT
Content-Type:
- application/json;charset=UTF-8
Transfer-Encoding:
- chunked
Connection:
- keep-alive
Cache-Control:
- private
Expires:
- Thu, 01 Jan 1970 00:00:00 UTC
X-Served-By:
- ip-10-143-141-59/10.143.141.59
Vary:
- Accept-Encoding
body:
encoding: ASCII-8BIT
string: |-
{
"q" : "qqqqqqq",
"from" : 0,
"to" : 10,
"params" : {
"sane" : [ ],
"q" : [ "qqqqqqq" ],
"from" : [ "0" ],
"app_key" : [ "<API_KEY>" ],
"to" : [ "10" ],
"app_id" : [ "<APP_ID>" ]
},
"more" : false,
"count" : 0,
"hits" : [ ]
}
http_version:
recorded_at: Fri, 10 Nov 2017 07:42:59 GMT
- request:
method: get
uri: https://api.edamam.com/search?app_id=<APP_ID>&app_key=<API_KEY>&from=&q=qqqqqqq&to=
body:
encoding: US-ASCII
string: ''
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept:
- "*/*"
User-Agent:
- Ruby
response:
status:
code: 500
message: Internal Server Error
headers:
Server:
- ngx_openresty
Date:
- Fri, 10 Nov 2017 07:42:59 GMT
Content-Type:
- text/html
Content-Length:
- '1194'
Connection:
- close
Vary:
- Accept-Encoding
Etag:
- '"511d9665-4aa"'
body:
encoding: ASCII-8BIT
string: "<!--[if IE 9]>\n<!DOCTYPE html>\n<html class=\"ie ie9 lte9\" xmlns=\"http://www.w3.org/1999/xhtml\"
xml:lang=\"bg\" lang=\"bg\">\n<![endif]-->\n\n<!--[if gt IE 9]>\n<!DOCTYPE
html>\n<html class=\"ie gt9\" xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"bg\"
lang=\"bg\">\n<![endif]-->\n\n<!--[if !IE]><!-->\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\"
xml:lang=\"bg\" lang=\"bg\">\n<!--<![endif]-->\n\n<head>\n <title>Error
500 | Edamam</title>\n\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\" />\n\t<meta http-equiv=\"Content-Language\" content=\"en\"
/>\n\t<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n\t\n\t<meta
http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\n\t<meta
name=\"viewport\" content=\"user-scalable=no, initial-scale=1.0, maximum-scale=1.0,
width=device-width\">\n\n\t<meta name=\"description\" content=\"Finding recipes
just got easier. Edamam has over 1 million recipes from more than 500 sites\"/>\n\t<meta
name=\"keywords\" content=\"edamam, recipes, food, nutritions, ingredients,
calories, servings\"/>\n\n\t<meta name=\"robots\" content=\"all,index,follow\"
/>\n\t<meta name=\"googlebot\" content=\"index,follow,noodp\" />\n\t<meta
name=\"msnbot\" content=\"all,index,follow\" />\n\t\n\t<meta name=\"verify-v1\"
content=\"Google Webmaster tools\" />\n\t<meta name=\"verify-v1\" content=\"Yahoo
Site Explorer\" />\n\t<meta name=\"verify-v1\" content=\"MSN Webmaster Center\"
/>\n\t\n\t<meta name=\"SKYPE_TOOLBAR\" content=\"SKYPE_TOOLBAR_PARSER_COMPATIBLE\"
/>\n\n\t<link type=\"image/x-icon\" rel=\"icon\" href=\"/favicon.ico\" />\n\t<link
type=\"image/x-icon\" rel=\"shortcut icon\" href=\"/favicon.ico\" />\n\t\n\t<link
rel=\"stylesheet\" type=\"text/css\" href=\"/css/general.css\" />\n\t<style
type=\"text/css\">\n\t\t/* ........................... */\n\t\t#head, #error-txt
{margin-top: 100px !important}\n\t\t\n\t\t@media only screen and (max-width:
599px), only screen and (max-height: 480px) and (max-width: 800px) {\n\t\t\t#head,
#error-txt {margin-top: 20px !important}\n\t\t}\n\t</style>\n\t\n\t<!--[if
lt IE 9]><script type=\"text/javascript\" src=\"/js/html5shiv.js\"></script><![endif]-->\n</head>\n\n<body
id=\"page-501\" class=\"tmpl-main sub-error\">\n\t<div id=\"general\">\n\t\t<header
class=\"gradient grd-header cf\">\n\t\t\t<div class=\"header-inner\">\n\t\t\t\t&nbsp;\n\t\t\t</div><!--
/header-inner -->\n\t\t</header>\n\t\t\n\t\t<section>\n\t\t\t<div id=\"main\">\n\t\t\t\t<div
id=\"head\">\n\t\t\t\t\t<a id=\"site-logo\" href=\"/\">Edamam</a>\n\t\t\t\t\t<span
id=\"site-slogan\" class=\"txt-n12a col-666 shd-1-1-0-FFF\">Eat better!</span>\n\t\t\t\t</div><!--
/head -->\n\n\t\t\t\t<div id=\"error-txt\">\n\t\t\t\t\t<p class=\"txt-n20g
col-FF8400 align-c pl10 pr10 pb10\">You can't make an omelette without breaking
some eggs. <br>We are in the kitchen - will be serving soon...</p>\n\t\t\t\t</div><!--
/error-txt -->\n\t\t\t</div><!-- /main -->\n\t\t</section>\n\t\t\n\t\t<footer
class=\"cf bgc-F2F2F2\">\n\t\t\t&nbsp;\n\t\t</footer>\n\t</div><!-- /general
-->\n</body>\n\n</html>"
http_version:
recorded_at: Fri, 10 Nov 2017 07:43:00 GMT
recorded_with: VCR 3.0.3
581 changes: 581 additions & 0 deletions test/cassettes/search.yml
7 changes: 0 additions & 7 deletions test/controllers/munchers_controller_test.rb

This file was deleted.

33 changes: 33 additions & 0 deletions test/controllers/recipes_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "test_helper"
#
describe RecipesController do
describe "index" do
it "returns success to access the index page" do # our home page
get root_path

must_respond_with :success
end # it returns success
end # end of index

describe "results" do
it "returns success if found results" do
q = "cheese"
VCR.use_cassette("search") do
EdamamApiMuncher.search(q, 10, 20).empty?.must_equal false
get results_path(q: q)
must_respond_with :success
end
end # end of it


it "redirects if search is invalid" do
q = ""
VCR.use_cassette("search") do
EdamamApiMuncher.search(q, 0, 10).empty?.must_equal true
get results_path(q: q)
must_redirect_to root_path
flash[:message].must_equal "Please enter a search word"
end
end
end
end # end of MunchersController