benschwarz-smoke 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/Rakefile +6 -0
  2. data/VERSION.yml +1 -1
  3. metadata +65 -196
  4. data/Gemfile +0 -10
  5. data/bin/edit_json.rb +0 -3
  6. data/bin/restclient +0 -3
  7. data/vendor/gems/cache/crack-0.1.1.gem +0 -0
  8. data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
  9. data/vendor/gems/cache/json-1.1.3.gem +0 -0
  10. data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
  11. data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
  12. data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
  13. data/vendor/gems/environment.rb +0 -83
  14. data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
  15. data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
  16. data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
  17. data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
  18. data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
  19. data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
  20. data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
  21. data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
  22. data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
  23. data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
  24. data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
  25. data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
  26. data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
  27. data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
  28. data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
  29. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
  30. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
  31. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
  32. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
  33. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
  34. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
  35. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
  36. data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
  37. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
  38. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
  39. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
  40. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
  41. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
  42. data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
  43. data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
  44. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
  45. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
  46. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
  47. data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
  48. data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
  49. data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
  50. data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
  51. data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
  52. data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
  53. data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
  54. data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
  55. data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
  56. data/vendor/gems/gems/json-1.1.3/GPL +0 -340
  57. data/vendor/gems/gems/json-1.1.3/README +0 -78
  58. data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
  59. data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
  60. data/vendor/gems/gems/json-1.1.3/TODO +0 -1
  61. data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
  62. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
  63. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
  64. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
  65. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
  66. data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
  67. data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
  68. data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
  69. data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
  70. data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
  71. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
  72. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
  73. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
  74. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
  75. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
  76. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
  77. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
  78. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
  79. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
  80. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
  81. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
  82. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
  83. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
  84. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
  85. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
  86. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
  87. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
  88. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
  89. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
  90. data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
  91. data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
  92. data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
  93. data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
  94. data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
  95. data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
  96. data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
  97. data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
  98. data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
  99. data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
  100. data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
  101. data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
  102. data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
  103. data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
  104. data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
  105. data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
  106. data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
  107. data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
  108. data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
  109. data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
  110. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
  111. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
  112. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
  113. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
  114. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
  115. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
  116. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
  117. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
  118. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
  119. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
  120. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
  121. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
  122. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
  123. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
  124. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
  125. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
  126. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
  127. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
  128. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
  129. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
  130. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
  131. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
  132. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
  133. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
  134. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
  135. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
  136. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
  137. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
  138. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
  139. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
  140. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
  141. data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
  142. data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
  143. data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
  144. data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
  145. data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
  146. data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
  147. data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
  148. data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
  149. data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
  150. data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
  151. data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
  152. data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
  153. data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
  154. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
  155. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
  156. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
  157. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
  158. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
  159. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
  160. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
  161. data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
  162. data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
  163. data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
  164. data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
  165. data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
  166. data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
  167. data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
  168. data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
  169. data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
  170. data/vendor/gems/gems/simple-rss-1.2/README +0 -43
  171. data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
  172. data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
  173. data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
  174. data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
  175. data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
  176. data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
  177. data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
  178. data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
  179. data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
  180. data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
  181. data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
  182. data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
  183. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
  184. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
  185. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
  186. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
  187. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
  188. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
  189. data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
  190. data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
  191. data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
  192. data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
  193. data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
  194. data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,10 +0,0 @@
1
- module FakeWeb
2
- module Response #:nodoc:
3
-
4
- def read_body(*args, &block)
5
- yield @body if block_given?
6
- @body
7
- end
8
-
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- module FakeWeb
2
- class StubSocket #:nodoc:
3
-
4
- def initialize(*args)
5
- end
6
-
7
- def closed?
8
- @closed ||= true
9
- end
10
-
11
- def readuntil(*args)
12
- end
13
-
14
- end
15
- end
@@ -1,22 +0,0 @@
1
- module FakeWeb
2
- module Utility #:nodoc:
3
-
4
- def self.decode_userinfo_from_header(header)
5
- header.sub(/^Basic /, "").unpack("m").first
6
- end
7
-
8
- def self.encode_unsafe_chars_in_userinfo(userinfo)
9
- unsafe_in_userinfo = /[^#{URI::REGEXP::PATTERN::UNRESERVED};&=+$,]|^(#{URI::REGEXP::PATTERN::ESCAPED})/
10
- userinfo.split(":").map { |part| URI.escape(part, unsafe_in_userinfo) }.join(":")
11
- end
12
-
13
- def self.strip_default_port_from_uri(uri)
14
- case uri
15
- when %r{^http://} then uri.sub(%r{:80(/|$)}, '\1')
16
- when %r{^https://} then uri.sub(%r{:443(/|$)}, '\1')
17
- else uri
18
- end
19
- end
20
-
21
- end
22
- end
@@ -1,2 +0,0 @@
1
- # So you can require "fakeweb" instead of "fake_web"
2
- require "fake_web"
@@ -1,12 +0,0 @@
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>&#9660;</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 &raquo;</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%>&nbsp;</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>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<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&nbsp;Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>&copy;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>
@@ -1,17 +0,0 @@
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>&#9660;</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 &raquo;</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%>&nbsp;</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>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<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&nbsp;Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>&copy;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
-
@@ -1,11 +0,0 @@
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>&#9660;</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 &raquo;</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%>&nbsp;</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>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<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&nbsp;Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>&copy;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>
@@ -1 +0,0 @@
1
- test example content
@@ -1,3 +0,0 @@
1
- line 1
2
- line 2
3
- line 3
@@ -1,85 +0,0 @@
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
@@ -1,54 +0,0 @@
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
@@ -1,92 +0,0 @@
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
@@ -1,518 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestFakeWeb < Test::Unit::TestCase
4
-
5
- def test_register_uri
6
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => "example")
7
- assert FakeWeb.registered_uri?(:get, 'http://mock/test_example.txt')
8
- end
9
-
10
- def test_register_uri_with_wrong_number_of_arguments
11
- assert_raises ArgumentError do
12
- FakeWeb.register_uri("http://example.com")
13
- end
14
- assert_raises ArgumentError do
15
- FakeWeb.register_uri(:get, "http://example.com", "/example", :body => "example")
16
- end
17
- end
18
-
19
- def test_registered_uri_with_wrong_number_of_arguments
20
- assert_raises ArgumentError do
21
- FakeWeb.registered_uri?
22
- end
23
- assert_raises ArgumentError do
24
- FakeWeb.registered_uri?(:get, "http://example.com", "/example")
25
- end
26
- end
27
-
28
- def test_response_for_with_wrong_number_of_arguments
29
- assert_raises ArgumentError do
30
- FakeWeb.response_for
31
- end
32
- assert_raises ArgumentError do
33
- FakeWeb.response_for(:get, "http://example.com", "/example")
34
- end
35
- end
36
-
37
- def test_register_uri_without_domain_name
38
- assert_raises URI::InvalidURIError do
39
- FakeWeb.register_uri(:get, 'test_example2.txt', File.dirname(__FILE__) + '/fixtures/test_example.txt')
40
- end
41
- end
42
-
43
- def test_register_uri_with_port_and_check_with_port
44
- FakeWeb.register_uri(:get, 'http://example.com:3000/', :body => 'foo')
45
- assert FakeWeb.registered_uri?(:get, 'http://example.com:3000/')
46
- end
47
-
48
- def test_register_uri_with_port_and_check_without_port
49
- FakeWeb.register_uri(:get, 'http://example.com:3000/', :body => 'foo')
50
- assert !FakeWeb.registered_uri?(:get, 'http://example.com/')
51
- end
52
-
53
- def test_register_uri_with_default_port_for_http_and_check_without_port
54
- FakeWeb.register_uri(:get, 'http://example.com:80/', :body => 'foo')
55
- assert FakeWeb.registered_uri?(:get, 'http://example.com/')
56
- end
57
-
58
- def test_register_uri_with_default_port_for_https_and_check_without_port
59
- FakeWeb.register_uri(:get, 'https://example.com:443/', :body => 'foo')
60
- assert FakeWeb.registered_uri?(:get, 'https://example.com/')
61
- end
62
-
63
- def test_register_uri_with_no_port_for_http_and_check_with_default_port
64
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
65
- assert FakeWeb.registered_uri?(:get, 'http://example.com:80/')
66
- end
67
-
68
- def test_register_uri_with_no_port_for_https_and_check_with_default_port
69
- FakeWeb.register_uri(:get, 'https://example.com/', :body => 'foo')
70
- assert FakeWeb.registered_uri?(:get, 'https://example.com:443/')
71
- end
72
-
73
- def test_register_uri_with_no_port_for_https_and_check_with_443_on_http
74
- FakeWeb.register_uri(:get, 'https://example.com/', :body => 'foo')
75
- assert !FakeWeb.registered_uri?(:get, 'http://example.com:443/')
76
- end
77
-
78
- def test_register_uri_with_no_port_for_http_and_check_with_80_on_https
79
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
80
- assert !FakeWeb.registered_uri?(:get, 'https://example.com:80/')
81
- end
82
-
83
- def test_register_uri_for_any_method_explicitly
84
- FakeWeb.register_uri(:any, "http://example.com/rpc_endpoint", :body => "OK")
85
- assert FakeWeb.registered_uri?(:get, "http://example.com/rpc_endpoint")
86
- assert FakeWeb.registered_uri?(:post, "http://example.com/rpc_endpoint")
87
- assert FakeWeb.registered_uri?(:put, "http://example.com/rpc_endpoint")
88
- assert FakeWeb.registered_uri?(:delete, "http://example.com/rpc_endpoint")
89
- assert FakeWeb.registered_uri?(:any, "http://example.com/rpc_endpoint")
90
- capture_stderr do # silence deprecation warning
91
- assert FakeWeb.registered_uri?("http://example.com/rpc_endpoint")
92
- end
93
- end
94
-
95
- def test_register_uri_for_get_method_only
96
- FakeWeb.register_uri(:get, "http://example.com/users", :body => "User list")
97
- assert FakeWeb.registered_uri?(:get, "http://example.com/users")
98
- assert !FakeWeb.registered_uri?(:post, "http://example.com/users")
99
- assert !FakeWeb.registered_uri?(:put, "http://example.com/users")
100
- assert !FakeWeb.registered_uri?(:delete, "http://example.com/users")
101
- assert !FakeWeb.registered_uri?(:any, "http://example.com/users")
102
- capture_stderr do # silence deprecation warning
103
- assert !FakeWeb.registered_uri?("http://example.com/users")
104
- end
105
- end
106
-
107
- def test_response_for_with_registered_uri
108
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
109
- assert_equal 'test example content', FakeWeb.response_for(:get, 'http://mock/test_example.txt').body
110
- end
111
-
112
- def test_response_for_with_unknown_uri
113
- assert_nil FakeWeb.response_for(:get, 'http://example.com/')
114
- end
115
-
116
- def test_response_for_with_put_method
117
- FakeWeb.register_uri(:put, "http://example.com", :body => "response")
118
- assert_equal 'response', FakeWeb.response_for(:put, "http://example.com").body
119
- end
120
-
121
- def test_response_for_with_any_method_explicitly
122
- FakeWeb.register_uri(:any, "http://example.com", :body => "response")
123
- assert_equal 'response', FakeWeb.response_for(:get, "http://example.com").body
124
- assert_equal 'response', FakeWeb.response_for(:any, "http://example.com").body
125
- end
126
-
127
- def test_content_for_registered_uri_with_port_and_request_with_port
128
- FakeWeb.register_uri(:get, 'http://example.com:3000/', :body => 'test example content')
129
- response = Net::HTTP.start('example.com', 3000) { |http| http.get('/') }
130
- assert_equal 'test example content', response.body
131
- end
132
-
133
- def test_content_for_registered_uri_with_default_port_for_http_and_request_without_port
134
- FakeWeb.register_uri(:get, 'http://example.com:80/', :body => 'test example content')
135
- response = Net::HTTP.start('example.com') { |http| http.get('/') }
136
- assert_equal 'test example content', response.body
137
- end
138
-
139
- def test_content_for_registered_uri_with_no_port_for_http_and_request_with_default_port
140
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'test example content')
141
- response = Net::HTTP.start('example.com', 80) { |http| http.get('/') }
142
- assert_equal 'test example content', response.body
143
- end
144
-
145
- def test_content_for_registered_uri_with_default_port_for_https_and_request_with_default_port
146
- FakeWeb.register_uri(:get, 'https://example.com:443/', :body => 'test example content')
147
- http = Net::HTTP.new('example.com', 443)
148
- http.use_ssl = true
149
- response = http.get('/')
150
- assert_equal 'test example content', response.body
151
- end
152
-
153
- def test_content_for_registered_uri_with_no_port_for_https_and_request_with_default_port
154
- FakeWeb.register_uri(:get, 'https://example.com/', :body => 'test example content')
155
- http = Net::HTTP.new('example.com', 443)
156
- http.use_ssl = true
157
- response = http.get('/')
158
- assert_equal 'test example content', response.body
159
- end
160
-
161
- def test_content_for_registered_uris_with_ports_on_same_domain_and_request_without_port
162
- FakeWeb.register_uri(:get, 'http://example.com:3000/', :body => 'port 3000')
163
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'port 80')
164
- response = Net::HTTP.start('example.com') { |http| http.get('/') }
165
- assert_equal 'port 80', response.body
166
- end
167
-
168
- def test_content_for_registered_uris_with_ports_on_same_domain_and_request_with_port
169
- FakeWeb.register_uri(:get, 'http://example.com:3000/', :body => 'port 3000')
170
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'port 80')
171
- response = Net::HTTP.start('example.com', 3000) { |http| http.get('/') }
172
- assert_equal 'port 3000', response.body
173
- end
174
-
175
- def test_content_for_registered_uri_with_get_method_only
176
- FakeWeb.allow_net_connect = false
177
- FakeWeb.register_uri(:get, "http://example.com/", :body => "test example content")
178
- http = Net::HTTP.new('example.com')
179
- assert_equal 'test example content', http.get('/').body
180
- assert_raises(FakeWeb::NetConnectNotAllowedError) { http.post('/', nil) }
181
- assert_raises(FakeWeb::NetConnectNotAllowedError) { http.put('/', nil) }
182
- assert_raises(FakeWeb::NetConnectNotAllowedError) { http.delete('/') }
183
- end
184
-
185
- def test_content_for_registered_uri_with_any_method_explicitly
186
- FakeWeb.allow_net_connect = false
187
- FakeWeb.register_uri(:any, "http://example.com/", :body => "test example content")
188
- http = Net::HTTP.new('example.com')
189
- assert_equal 'test example content', http.get('/').body
190
- assert_equal 'test example content', http.post('/', nil).body
191
- assert_equal 'test example content', http.put('/', nil).body
192
- assert_equal 'test example content', http.delete('/').body
193
- end
194
-
195
- def test_content_for_registered_uri_with_any_method_implicitly
196
- FakeWeb.allow_net_connect = false
197
- capture_stderr do # silence deprecation warning
198
- FakeWeb.register_uri("http://example.com/", :body => "test example content")
199
- end
200
-
201
- http = Net::HTTP.new('example.com')
202
- assert_equal 'test example content', http.get('/').body
203
- assert_equal 'test example content', http.post('/', nil).body
204
- assert_equal 'test example content', http.put('/', nil).body
205
- assert_equal 'test example content', http.delete('/').body
206
- end
207
-
208
- def test_mock_request_with_block
209
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
210
- response = Net::HTTP.start('mock') { |http| http.get('/test_example.txt') }
211
- assert_equal 'test example content', response.body
212
- end
213
-
214
- def test_request_with_registered_body_yields_the_response_body_to_a_request_block
215
- FakeWeb.register_uri(:get, "http://example.com", :body => "content")
216
- body = nil
217
- Net::HTTP.start("example.com") do |http|
218
- http.get("/") do |response_body|
219
- body = response_body
220
- end
221
- end
222
- assert_equal "content", body
223
- end
224
-
225
- def test_request_with_registered_response_yields_the_response_body_to_a_request_block
226
- fake_response = Net::HTTPOK.new('1.1', '200', 'OK')
227
- fake_response.instance_variable_set(:@body, "content")
228
- FakeWeb.register_uri(:get, 'http://example.com', :response => fake_response)
229
- body = nil
230
- Net::HTTP.start("example.com") do |http|
231
- http.get("/") do |response_body|
232
- body = response_body
233
- end
234
- end
235
- assert_equal "content", body
236
- end
237
-
238
- def test_mock_request_with_undocumented_full_uri_argument_style
239
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
240
- response = Net::HTTP.start('mock') { |query| query.get('http://mock/test_example.txt') }
241
- assert_equal 'test example content', response.body
242
- end
243
-
244
- def test_mock_request_with_undocumented_full_uri_argument_style_and_query
245
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt?a=b', :body => 'test query content')
246
- response = Net::HTTP.start('mock') { |query| query.get('http://mock/test_example.txt?a=b') }
247
- assert_equal 'test query content', response.body
248
- end
249
-
250
- def test_mock_post
251
- FakeWeb.register_uri(:post, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
252
- response = Net::HTTP.start('mock') { |query| query.post('/test_example.txt', '') }
253
- assert_equal 'test example content', response.body
254
- end
255
-
256
- def test_mock_post_with_string_as_registered_uri
257
- FakeWeb.register_uri(:post, 'http://mock/test_string.txt', :body => 'foo')
258
- response = Net::HTTP.start('mock') { |query| query.post('/test_string.txt', '') }
259
- assert_equal 'foo', response.body
260
- end
261
-
262
- def test_mock_get_with_request_as_registered_uri
263
- fake_response = Net::HTTPOK.new('1.1', '200', 'OK')
264
- FakeWeb.register_uri(:get, 'http://mock/test_response', :response => fake_response)
265
- response = Net::HTTP.start('mock') { |query| query.get('/test_response') }
266
- assert_equal fake_response, response
267
- end
268
-
269
- def test_mock_get_with_request_from_file_as_registered_uri
270
- FakeWeb.register_uri(:get, 'http://www.google.com/', :response => File.dirname(__FILE__) + '/fixtures/google_response_without_transfer_encoding')
271
- response = Net::HTTP.start('www.google.com') { |query| query.get('/') }
272
- assert_equal '200', response.code
273
- assert response.body.include?('<title>Google</title>')
274
- end
275
-
276
- def test_mock_post_with_request_from_file_as_registered_uri
277
- FakeWeb.register_uri(:post, 'http://www.google.com/', :response => File.dirname(__FILE__) + '/fixtures/google_response_without_transfer_encoding')
278
- response = Net::HTTP.start('www.google.com') { |query| query.post('/', '') }
279
- assert_equal "200", response.code
280
- assert response.body.include?('<title>Google</title>')
281
- end
282
-
283
- def test_proxy_request
284
- FakeWeb.register_uri(:get, 'http://www.example.com/', :body => "hello world")
285
- FakeWeb.register_uri(:get, 'http://your.proxy.host/', :body => "lala")
286
-
287
- response = nil
288
- Net::HTTP::Proxy('your.proxy.host', 8080).start('www.example.com') do |http|
289
- response = http.get('/')
290
- end
291
- assert_equal "hello world", response.body
292
- end
293
-
294
- def test_https_request
295
- FakeWeb.register_uri(:get, 'https://www.example.com/', :body => "Hello World")
296
- http = Net::HTTP.new('www.example.com', 443)
297
- http.use_ssl = true
298
- response = http.get('/')
299
- assert_equal "Hello World", response.body
300
- end
301
-
302
- def test_register_unimplemented_response
303
- FakeWeb.register_uri(:get, 'http://mock/unimplemented', :response => 1)
304
- assert_raises StandardError do
305
- Net::HTTP.start('mock') { |q| q.get('/unimplemented') }
306
- end
307
- end
308
-
309
- def test_real_http_request
310
- FakeWeb.allow_net_connect = true
311
- setup_expectations_for_real_apple_hot_news_request
312
-
313
- resp = nil
314
- Net::HTTP.start('images.apple.com') do |query|
315
- resp = query.get('/main/rss/hotnews/hotnews.rss')
316
- end
317
- assert resp.body.include?('Apple')
318
- assert resp.body.include?('News')
319
- end
320
-
321
- def test_real_http_request_with_undocumented_full_uri_argument_style
322
- FakeWeb.allow_net_connect = true
323
- setup_expectations_for_real_apple_hot_news_request(:path => 'http://images.apple.com/main/rss/hotnews/hotnews.rss')
324
-
325
- resp = nil
326
- Net::HTTP.start('images.apple.com') do |query|
327
- resp = query.get('http://images.apple.com/main/rss/hotnews/hotnews.rss')
328
- end
329
- assert resp.body.include?('Apple')
330
- assert resp.body.include?('News')
331
- end
332
-
333
- def test_real_https_request
334
- FakeWeb.allow_net_connect = true
335
- setup_expectations_for_real_apple_hot_news_request(:port => 443)
336
-
337
- http = Net::HTTP.new('images.apple.com', 443)
338
- http.use_ssl = true
339
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE # silence certificate warning
340
- response = http.get('/main/rss/hotnews/hotnews.rss')
341
- assert response.body.include?('Apple')
342
- assert response.body.include?('News')
343
- end
344
-
345
- def test_real_request_on_same_domain_as_mock
346
- FakeWeb.allow_net_connect = true
347
- setup_expectations_for_real_apple_hot_news_request
348
-
349
- FakeWeb.register_uri(:get, 'http://images.apple.com/test_string.txt', :body => 'foo')
350
-
351
- resp = nil
352
- Net::HTTP.start('images.apple.com') do |query|
353
- resp = query.get('/main/rss/hotnews/hotnews.rss')
354
- end
355
- assert resp.body.include?('Apple')
356
- assert resp.body.include?('News')
357
- end
358
-
359
- def test_mock_request_on_real_domain
360
- FakeWeb.register_uri(:get, 'http://images.apple.com/test_string.txt', :body => 'foo')
361
- resp = nil
362
- Net::HTTP.start('images.apple.com') do |query|
363
- resp = query.get('/test_string.txt')
364
- end
365
- assert_equal 'foo', resp.body
366
- end
367
-
368
- def test_mock_post_that_raises_exception
369
- FakeWeb.register_uri(:post, 'http://mock/raising_exception.txt', :exception => StandardError)
370
- assert_raises(StandardError) do
371
- Net::HTTP.start('mock') do |query|
372
- query.post('/raising_exception.txt', 'some data')
373
- end
374
- end
375
- end
376
-
377
- def test_mock_post_that_raises_an_http_error
378
- FakeWeb.register_uri(:post, 'http://mock/raising_exception.txt', :exception => Net::HTTPError)
379
- assert_raises(Net::HTTPError) do
380
- Net::HTTP.start('mock') do |query|
381
- query.post('/raising_exception.txt', '')
382
- end
383
- end
384
- end
385
-
386
- def test_raising_an_exception_that_requires_an_argument_to_instantiate
387
- FakeWeb.register_uri(:get, "http://example.com/timeout.txt", :exception => Timeout::Error)
388
- assert_raises(Timeout::Error) do
389
- Net::HTTP.get(URI.parse("http://example.com/timeout.txt"))
390
- end
391
- end
392
-
393
- def test_mock_instance_syntax
394
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
395
- response = nil
396
- uri = URI.parse('http://mock/test_example.txt')
397
- http = Net::HTTP.new(uri.host, uri.port)
398
- response = http.start do
399
- http.get(uri.path)
400
- end
401
-
402
- assert_equal 'test example content', response.body
403
- end
404
-
405
- def test_mock_via_nil_proxy
406
- response = nil
407
- proxy_address = nil
408
- proxy_port = nil
409
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
410
- uri = URI.parse('http://mock/test_example.txt')
411
- http = Net::HTTP::Proxy(proxy_address, proxy_port).new(
412
- uri.host, (uri.port or 80))
413
- response = http.start do
414
- http.get(uri.path)
415
- end
416
-
417
- assert_equal 'test example content', response.body
418
- end
419
-
420
- def test_response_type
421
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => "test")
422
- response = Net::HTTP.start('mock') { |http| http.get('/test_example.txt') }
423
- assert_kind_of Net::HTTPSuccess, response
424
- end
425
-
426
- def test_mock_request_that_raises_an_http_error_with_a_specific_status
427
- FakeWeb.register_uri(:get, 'http://mock/raising_exception.txt', :exception => Net::HTTPError, :status => ['404', 'Not Found'])
428
- exception = assert_raises(Net::HTTPError) do
429
- Net::HTTP.start('mock') { |http| http.get('/raising_exception.txt') }
430
- end
431
- assert_equal '404', exception.response.code
432
- assert_equal 'Not Found', exception.response.msg
433
- end
434
-
435
- def test_mock_rotate_responses
436
- FakeWeb.register_uri(:get, 'http://mock/multiple_test_example.txt',
437
- [ {:body => File.dirname(__FILE__) + '/fixtures/test_example.txt', :times => 2},
438
- {:body => "thrice", :times => 3},
439
- {:body => "ever_more"} ])
440
-
441
- uri = URI.parse('http://mock/multiple_test_example.txt')
442
- 2.times { assert_equal 'test example content', Net::HTTP.get(uri) }
443
- 3.times { assert_equal 'thrice', Net::HTTP.get(uri) }
444
- 4.times { assert_equal 'ever_more', Net::HTTP.get(uri) }
445
- end
446
-
447
- def test_mock_request_using_response_with_transfer_encoding_header_has_valid_transfer_encoding_header
448
- FakeWeb.register_uri(:get, 'http://www.google.com/', :response => File.dirname(__FILE__) + '/fixtures/google_response_with_transfer_encoding')
449
- response = Net::HTTP.start('www.google.com') { |query| query.get('/') }
450
- assert_not_nil response['transfer-encoding']
451
- assert response['transfer-encoding'] == 'chunked'
452
- end
453
-
454
- def test_mock_request_using_response_without_transfer_encoding_header_does_not_have_a_transfer_encoding_header
455
- FakeWeb.register_uri(:get, 'http://www.google.com/', :response => File.dirname(__FILE__) + '/fixtures/google_response_without_transfer_encoding')
456
- response = nil
457
- response = Net::HTTP.start('www.google.com') { |query| query.get('/') }
458
- assert !response.key?('transfer-encoding')
459
- end
460
-
461
- def test_mock_request_using_response_from_curl_has_original_transfer_encoding_header
462
- FakeWeb.register_uri(:get, 'http://www.google.com/', :response => File.dirname(__FILE__) + '/fixtures/google_response_from_curl')
463
- response = Net::HTTP.start('www.google.com') { |query| query.get('/') }
464
- assert_not_nil response['transfer-encoding']
465
- assert response['transfer-encoding'] == 'chunked'
466
- end
467
-
468
- def test_txt_file_should_have_three_lines
469
- FakeWeb.register_uri(:get, 'http://www.google.com/', :body => File.dirname(__FILE__) + '/fixtures/test_txt_file')
470
- response = Net::HTTP.start('www.google.com') { |query| query.get('/') }
471
- assert response.body.split(/\n/).size == 3, "response has #{response.body.split(/\n/).size} lines should have 3"
472
- end
473
-
474
- def test_requiring_fakeweb_instead_of_fake_web
475
- require "fakeweb"
476
- end
477
-
478
- def test_registering_with_string_containing_null_byte
479
- # Regression test for File.exists? raising an ArgumentError ("string
480
- # contains null byte") since :response first tries to find by filename.
481
- # The string should be treated as a response body, instead, and an
482
- # EOFError is raised when the byte is encountered.
483
- FakeWeb.register_uri(:get, "http://example.com", :response => "test\0test")
484
- assert_raise EOFError do
485
- Net::HTTP.get(URI.parse("http://example.com"))
486
- end
487
-
488
- FakeWeb.register_uri(:get, "http://example.com", :body => "test\0test")
489
- body = Net::HTTP.get(URI.parse("http://example.com"))
490
- assert_equal "test\0test", body
491
- end
492
-
493
- def test_registering_with_string_that_is_a_directory_name
494
- # Similar to above, but for Errno::EISDIR being raised since File.exists?
495
- # returns true for directories
496
- FakeWeb.register_uri(:get, "http://example.com", :response => File.dirname(__FILE__))
497
- assert_raise EOFError do
498
- body = Net::HTTP.get(URI.parse("http://example.com"))
499
- end
500
-
501
- FakeWeb.register_uri(:get, "http://example.com", :body => File.dirname(__FILE__))
502
- body = Net::HTTP.get(URI.parse("http://example.com"))
503
- assert_equal File.dirname(__FILE__), body
504
- end
505
-
506
- def test_http_version_from_string_response
507
- FakeWeb.register_uri(:get, "http://example.com", :body => "example")
508
- response = Net::HTTP.start("example.com") { |http| http.get("/") }
509
- assert_equal "1.0", response.http_version
510
- end
511
-
512
- def test_http_version_from_file_response
513
- FakeWeb.register_uri(:get, "http://example.com", :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
514
- response = Net::HTTP.start("example.com") { |http| http.get("/") }
515
- assert_equal "1.0", response.http_version
516
- end
517
-
518
- end