ivanvr-fakeweb 1.2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +163 -0
- data/LICENSE.txt +281 -0
- data/README.rdoc +206 -0
- data/Rakefile +76 -0
- data/lib/fake_web/ext/net_http.rb +72 -0
- data/lib/fake_web/registry.rb +159 -0
- data/lib/fake_web/responder.rb +120 -0
- data/lib/fake_web/response.rb +10 -0
- data/lib/fake_web/stub_socket.rb +15 -0
- data/lib/fake_web/utility.rb +44 -0
- data/lib/fake_web.rb +173 -0
- data/lib/fakeweb.rb +2 -0
- data/test/fixtures/google_response_from_curl +12 -0
- data/test/fixtures/google_response_with_transfer_encoding +17 -0
- data/test/fixtures/google_response_without_transfer_encoding +11 -0
- data/test/fixtures/test_example.txt +1 -0
- data/test/fixtures/test_txt_file +3 -0
- data/test/test_allow_net_connect.rb +85 -0
- data/test/test_deprecations.rb +54 -0
- data/test/test_fake_authentication.rb +92 -0
- data/test/test_fake_web.rb +526 -0
- data/test/test_fake_web_open_uri.rb +58 -0
- data/test/test_helper.rb +74 -0
- data/test/test_missing_open_uri.rb +25 -0
- data/test/test_precedence.rb +79 -0
- data/test/test_query_string.rb +45 -0
- data/test/test_regexes.rb +152 -0
- data/test/test_response_headers.rb +73 -0
- data/test/test_trailing_slashes.rb +53 -0
- data/test/test_utility.rb +91 -0
- metadata +127 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Cache-Control: private, max-age=0
|
3
|
+
Date: Sun, 01 Feb 2009 02:16:24 GMT
|
4
|
+
Expires: -1
|
5
|
+
Content-Type: text/html; charset=ISO-8859-1
|
6
|
+
Set-Cookie: PREF=ID=a6d9b5f5a4056dfe:TM=1233454584:LM=1233454584:S=U9pSwSu4eQwOPenX; expires=Tue, 01-Feb-2011 02:16:24 GMT; path=/; domain=.google.com
|
7
|
+
Server: gws
|
8
|
+
Transfer-Encoding: chunked
|
9
|
+
|
10
|
+
<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><script>var _gjwl=location;function _gjuc(){var a=_gjwl.hash;if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a=a.substring(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)=="&")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var e=a.substring(d,b);if(e.indexOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(e=="cad=h")return 0;c=b}_gjwl.href="search?"+a+"&cad=h";return 1}}return 0};
|
11
|
+
window._gjuc && location.hash && _gjuc();</script><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>window.google={kEI:"-AWFSZ6qFYuUswO9j5HIDQ",kEXPI:"17259,19547",kHL:"en"};
|
12
|
+
google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#";d.parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/nav_logo3.png'" topmargin=3 marginheight=3><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>▼</small></a><div id=gbi> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb2>Video</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://finance.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com/intl/en/options/" class=gb2>even more »</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276><br><br><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap><input name=hl type=hidden value=en><input type=hidden name=ie value="ISO-8859-1"><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2> <a href=/advanced_search?hl=en>Advanced Search</a><br> <a href=/preferences?hl=en>Preferences</a><br> <a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><font size=-1>Share what you know. <a href="/aclk?sa=L&ai=CYhslHwSFSZH6LIHusAPEsc2eBfv77nqP3YC9CsHZnNkTEAEgwVRQypDftPn_____AWDJBqoECU_QbUVlfOdxZw&num=1&sig=AGiWqtwRgqw8y_kza6RGKxBrCstaXkDJ7A&q=http://knol.google.com">Write a Knol</a>.</font><br><br><br><font size=-1><a href="/intl/en/ads/">Advertising Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>©2009 - <a href="/intl/en/privacy.html">Privacy</a></font></p></center></body><script>if(google.y)google.y.first=[];window.setTimeout(function(){var xjs=document.createElement('script');xjs.src='/extern_js/f/CgJlbhICdXMgACswCjgVLCswDjgELCswGDgDLA/L3N5xu59nDE.js';document.getElementsByTagName('head')[0].appendChild(xjs)},0);google.y.first.push(function(){google.ac.i(document.f,document.f.q,'','')})</script><script>function _gjp() {!(location.hash && _gjuc()) && setTimeout(_gjp, 500);}window._gjuc && _gjp();</script></html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Cache-Control: private, max-age=0
|
3
|
+
Date: Sun, 01 Feb 2009 01:54:36 GMT
|
4
|
+
Expires: -1
|
5
|
+
Content-Type: text/html; charset=ISO-8859-1
|
6
|
+
Set-Cookie: PREF=ID=4320bcaa30d097de:TM=1233453276:LM=1233453276:S=Eio39bg_nIabTxzL; expires=Tue, 01-Feb-2011 01:54:36 GMT; path=/; domain=.google.com
|
7
|
+
Server: gws
|
8
|
+
Transfer-Encoding: chunked
|
9
|
+
|
10
|
+
fef
|
11
|
+
<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><script>var _gjwl=location;function _gjuc(){var a=_gjwl.hash;if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a=a.substring(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)=="&")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var e=a.substring(d,b);if(e.indexOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(e=="cad=h")return 0;c=b}_gjwl.href="search?"+a+"&cad=h";return 1}}return 0};
|
12
|
+
window._gjuc && location.hash && _gjuc();</script><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>window.google={kEI:"3ACFSYC6EKTcswOL4_nBDQ",kEXPI:"17259,19463",kHL:"en"};
|
13
|
+
google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#";d.parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/nav_logo3.png'" topmargin=3 marginheight=3><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>▼</small></a><div id=gbi> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb2>Video</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://finance.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http
|
14
|
+
a27
|
15
|
+
://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com/intl/en/options/" class=gb2>even more »</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276><br><br><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap><input name=hl type=hidden value=en><input type=hidden name=ie value="ISO-8859-1"><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2> <a href=/advanced_search?hl=en>Advanced Search</a><br> <a href=/preferences?hl=en>Preferences</a><br> <a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><font size=-1>Share what you know. <a href="/aclk?sa=L&ai=CFL7HzwCFSZCnCJSwsQPm842HB_v77nqP3YC9CsHZnNkTEAEgwVRQypDftPn_____AWDJBqoECU_Q1sTewQNSbw&num=1&sig=AGiWqtyz-UiOD3EpsSp4k3n8A7zooeg48g&q=http://knol.google.com">Write a Knol</a>.</font><br><br><br><font size=-1><a href="/intl/en/ads/">Advertising Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>©2009 - <a href="/intl/en/privacy.html">Privacy</a></font></p></center></body><script>if(google.y)google.y.first=[];window.setTimeout(function(){var xjs=document.createElement('script');xjs.src='/extern_js/f/CgJlbhICdXMgACswCjgVLCswDjgELCswGDgDLA/L3N5xu59nDE.js';document.getElementsByTagName('head')[0].appendChild(xjs)},0);google.y.first.push(function(){google.ac.i(document.f,document.f.q,'','')})</script><script>function _gjp() {!(location.hash && _gjuc()) && setTimeout(_gjp, 500);}window._gjuc && _gjp();</script></html>
|
16
|
+
0
|
17
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.0 200 OK
|
2
|
+
Cache-Control: private, max-age=0
|
3
|
+
Date: Sun, 01 Feb 2009 01:55:33 GMT
|
4
|
+
Expires: -1
|
5
|
+
Content-Type: text/html; charset=ISO-8859-1
|
6
|
+
Set-Cookie: PREF=ID=3c140c3eb4c4f516:TM=1233453333:LM=1233453333:S=OH7sElk2hOWkb9ot; expires=Tue, 01-Feb-2011 01:55:33 GMT; path=/; domain=.google.com
|
7
|
+
Server: gws
|
8
|
+
|
9
|
+
<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><script>var _gjwl=location;function _gjuc(){var a=_gjwl.hash;if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a=a.substring(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)=="&")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var e=a.substring(d,b);if(e.indexOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(e=="cad=h")return 0;c=b}_gjwl.href="search?"+a+"&cad=h";return 1}}return 0};
|
10
|
+
window._gjuc && location.hash && _gjuc();</script><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>window.google={kEI:"FQGFSY2rG5eSswOKpsHeDQ",kEXPI:"17259",kHL:"en"};
|
11
|
+
google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#";d.parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="document.f.q.focus();if(document.images)new Image().src='/images/nav_logo3.png'" topmargin=3 marginheight=3><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>▼</small></a><div id=gbi> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb2>Video</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://finance.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com/intl/en/options/" class=gb2>even more »</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276><br><br><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap><input name=hl type=hidden value=en><input type=hidden name=ie value="ISO-8859-1"><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2> <a href=/advanced_search?hl=en>Advanced Search</a><br> <a href=/preferences?hl=en>Preferences</a><br> <a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><font size=-1>Share what you know. <a href="/aclk?sa=L&ai=ClyBp_v-EScTWD4W2tQOxoqSkB_v77nqP3YC9CsHZnNkTEAEgwVRQypDftPn_____AWDJBqoECU_QphTjHaZ5QA&num=1&sig=AGiWqtwtBqZ-zra3DJd_1chQKhKGf7lMVg&q=http://knol.google.com">Write a Knol</a>.</font><br><br><br><font size=-1><a href="/intl/en/ads/">Advertising Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>©2009 - <a href="/intl/en/privacy.html">Privacy</a></font></p></center></body><script>if(google.y)google.y.first=[];window.setTimeout(function(){var xjs=document.createElement('script');xjs.src='/extern_js/f/CgJlbhICdXMgACswCjgNLCswDjgELCswGDgDLA/oTKXc0xdkmY.js';document.getElementsByTagName('head')[0].appendChild(xjs)},0);google.y.first.push(function(){google.ac.i(document.f,document.f.q,'','')})</script><script>function _gjp() {!(location.hash && _gjuc()) && setTimeout(_gjp, 500);}window._gjuc && _gjp();</script></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
test example content
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class TestFakeWebAllowNetConnect < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_unregistered_requests_are_passed_through_when_allow_net_connect_is_true
|
6
|
+
FakeWeb.allow_net_connect = true
|
7
|
+
setup_expectations_for_real_apple_hot_news_request
|
8
|
+
Net::HTTP.get(URI.parse("http://images.apple.com/main/rss/hotnews/hotnews.rss"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_raises_for_unregistered_requests_when_allow_net_connect_is_false
|
12
|
+
FakeWeb.allow_net_connect = false
|
13
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
14
|
+
Net::HTTP.get(URI.parse("http://example.com/"))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_exception_message_includes_unregistered_request_method_and_uri_but_no_default_port
|
19
|
+
FakeWeb.allow_net_connect = false
|
20
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
21
|
+
Net::HTTP.get(URI.parse("http://example.com/"))
|
22
|
+
end
|
23
|
+
assert exception.message.include?("GET http://example.com/")
|
24
|
+
|
25
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
26
|
+
http = Net::HTTP.new("example.com", 443)
|
27
|
+
http.use_ssl = true
|
28
|
+
http.get("/")
|
29
|
+
end
|
30
|
+
assert exception.message.include?("GET https://example.com/")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_exception_message_includes_unregistered_request_port_when_not_default
|
34
|
+
FakeWeb.allow_net_connect = false
|
35
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
36
|
+
Net::HTTP.start("example.com", 8000) { |http| http.get("/") }
|
37
|
+
end
|
38
|
+
assert exception.message.include?("GET http://example.com:8000/")
|
39
|
+
|
40
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
41
|
+
http = Net::HTTP.new("example.com", 4433)
|
42
|
+
http.use_ssl = true
|
43
|
+
http.get("/")
|
44
|
+
end
|
45
|
+
assert exception.message.include?("GET https://example.com:4433/")
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_exception_message_includes_unregistered_request_port_when_not_default_with_path
|
49
|
+
FakeWeb.allow_net_connect = false
|
50
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
51
|
+
Net::HTTP.start("example.com", 8000) { |http| http.get("/test") }
|
52
|
+
end
|
53
|
+
assert exception.message.include?("GET http://example.com:8000/test")
|
54
|
+
|
55
|
+
exception = assert_raise FakeWeb::NetConnectNotAllowedError do
|
56
|
+
http = Net::HTTP.new("example.com", 4433)
|
57
|
+
http.use_ssl = true
|
58
|
+
http.get("/test")
|
59
|
+
end
|
60
|
+
assert exception.message.include?("GET https://example.com:4433/test")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_question_mark_method_returns_true_after_setting_allow_net_connect_to_true
|
64
|
+
FakeWeb.allow_net_connect = true
|
65
|
+
assert FakeWeb.allow_net_connect?
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_question_mark_method_returns_false_after_setting_allow_net_connect_to_false
|
69
|
+
FakeWeb.allow_net_connect = false
|
70
|
+
assert !FakeWeb.allow_net_connect?
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
class TestFakeWebAllowNetConnectWithCleanState < Test::Unit::TestCase
|
77
|
+
# Our test_helper.rb sets allow_net_connect = false in an inherited #setup
|
78
|
+
# method. Disable that here to test the default setting.
|
79
|
+
def setup; end
|
80
|
+
def teardown; end
|
81
|
+
|
82
|
+
def test_allow_net_connect_is_true_by_default
|
83
|
+
assert FakeWeb.allow_net_connect?
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class TestDeprecations < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_register_uri_without_method_argument_prints_deprecation_warning
|
6
|
+
warning = capture_stderr do
|
7
|
+
FakeWeb.register_uri("http://example.com", :body => "test")
|
8
|
+
end
|
9
|
+
assert_match /deprecation warning: fakeweb/i, warning
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_registered_uri_without_method_argument_prints_deprecation_warning
|
13
|
+
warning = capture_stderr do
|
14
|
+
FakeWeb.registered_uri?("http://example.com")
|
15
|
+
end
|
16
|
+
assert_match /deprecation warning: fakeweb/i, warning
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_response_for_without_method_argument_prints_deprecation_warning
|
20
|
+
warning = capture_stderr do
|
21
|
+
FakeWeb.response_for("http://example.com")
|
22
|
+
end
|
23
|
+
assert_match /deprecation warning: fakeweb/i, warning
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_register_uri_without_method_argument_prints_deprecation_warning_with_correct_caller
|
27
|
+
warning = capture_stderr do
|
28
|
+
FakeWeb.register_uri("http://example.com", :body => "test")
|
29
|
+
end
|
30
|
+
assert_match /Called at.*?test_deprecations\.rb/i, warning
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_register_uri_with_string_option_prints_deprecation_warning
|
34
|
+
warning = capture_stderr do
|
35
|
+
FakeWeb.register_uri(:get, "http://example.com", :string => "test")
|
36
|
+
end
|
37
|
+
assert_match /deprecation warning: fakeweb's :string option/i, warning
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_register_uri_with_file_option_prints_deprecation_warning
|
41
|
+
warning = capture_stderr do
|
42
|
+
FakeWeb.register_uri(:get, "http://example.com", :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
|
43
|
+
end
|
44
|
+
assert_match /deprecation warning: fakeweb's :file option/i, warning
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_register_uri_with_string_option_prints_deprecation_warning_with_correct_caller
|
48
|
+
warning = capture_stderr do
|
49
|
+
FakeWeb.register_uri(:get, "http://example.com", :string => "test")
|
50
|
+
end
|
51
|
+
assert_match /Called at.*?test_deprecations\.rb/i, warning
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class TestFakeAuthentication < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_register_uri_with_authentication
|
6
|
+
FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example")
|
7
|
+
assert FakeWeb.registered_uri?(:get, 'http://user:pass@mock/test_example.txt')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_register_uri_with_authentication_doesnt_trigger_without
|
11
|
+
FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example")
|
12
|
+
assert !FakeWeb.registered_uri?(:get, 'http://mock/test_example.txt')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_register_uri_with_authentication_doesnt_trigger_with_incorrect_credentials
|
16
|
+
FakeWeb.register_uri(:get, 'http://user:pass@mock/test_example.txt', :body => "example")
|
17
|
+
assert !FakeWeb.registered_uri?(:get, 'http://user:wrong@mock/test_example.txt')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_unauthenticated_request
|
21
|
+
FakeWeb.register_uri(:get, 'http://mock/auth.txt', :body => 'unauthorized')
|
22
|
+
http = Net::HTTP.new('mock', 80)
|
23
|
+
req = Net::HTTP::Get.new('/auth.txt')
|
24
|
+
assert_equal 'unauthorized', http.request(req).body
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_authenticated_request
|
28
|
+
FakeWeb.register_uri(:get, 'http://user:pass@mock/auth.txt', :body => 'authorized')
|
29
|
+
http = Net::HTTP.new('mock',80)
|
30
|
+
req = Net::HTTP::Get.new('/auth.txt')
|
31
|
+
req.basic_auth 'user', 'pass'
|
32
|
+
assert_equal 'authorized', http.request(req).body
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_authenticated_request_where_only_userinfo_differs
|
36
|
+
FakeWeb.register_uri(:get, 'http://user:pass@mock/auth.txt', :body => 'first user')
|
37
|
+
FakeWeb.register_uri(:get, 'http://user2:pass@mock/auth.txt', :body => 'second user')
|
38
|
+
http = Net::HTTP.new('mock')
|
39
|
+
req = Net::HTTP::Get.new('/auth.txt')
|
40
|
+
req.basic_auth 'user2', 'pass'
|
41
|
+
assert_equal 'second user', http.request(req).body
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_basic_auth_support_is_transparent_to_oauth
|
45
|
+
FakeWeb.register_uri(:get, "http://sp.example.com/protected", :body => "secret")
|
46
|
+
|
47
|
+
# from http://oauth.net/core/1.0/#auth_header
|
48
|
+
auth_header = <<-HEADER
|
49
|
+
OAuth realm="http://sp.example.com/",
|
50
|
+
oauth_consumer_key="0685bd9184jfhq22",
|
51
|
+
oauth_token="ad180jjd733klru7",
|
52
|
+
oauth_signature_method="HMAC-SHA1",
|
53
|
+
oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
|
54
|
+
oauth_timestamp="137131200",
|
55
|
+
oauth_nonce="4572616e48616d6d65724c61686176",
|
56
|
+
oauth_version="1.0"
|
57
|
+
HEADER
|
58
|
+
auth_header.gsub!(/\s+/, " ").strip!
|
59
|
+
|
60
|
+
http = Net::HTTP.new("sp.example.com", 80)
|
61
|
+
response = nil
|
62
|
+
http.start do |request|
|
63
|
+
response = request.get("/protected", {"authorization" => auth_header})
|
64
|
+
end
|
65
|
+
assert_equal "secret", response.body
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_basic_auth_when_userinfo_contains_allowed_unencoded_characters
|
69
|
+
FakeWeb.register_uri(:get, "http://roses&hel1o,(+$):so;longs=@example.com", :body => "authorized")
|
70
|
+
http = Net::HTTP.new("example.com")
|
71
|
+
request = Net::HTTP::Get.new("/")
|
72
|
+
request.basic_auth("roses&hel1o,(+$)", "so;longs=")
|
73
|
+
assert_equal "authorized", http.request(request).body
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_basic_auth_when_userinfo_contains_encoded_at_sign
|
77
|
+
FakeWeb.register_uri(:get, "http://user%40example.com:secret@example.com", :body => "authorized")
|
78
|
+
http = Net::HTTP.new("example.com")
|
79
|
+
request = Net::HTTP::Get.new("/")
|
80
|
+
request.basic_auth("user@example.com", "secret")
|
81
|
+
assert_equal "authorized", http.request(request).body
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_basic_auth_when_userinfo_contains_allowed_encoded_characters
|
85
|
+
FakeWeb.register_uri(:get, "http://us%20er:sec%20%2F%2Fret%3F@example.com", :body => "authorized")
|
86
|
+
http = Net::HTTP.new("example.com")
|
87
|
+
request = Net::HTTP::Get.new("/")
|
88
|
+
request.basic_auth("us er", "sec //ret?")
|
89
|
+
assert_equal "authorized", http.request(request).body
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|