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,76 +0,0 @@
1
- puts "Using ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
2
-
3
- require 'rubygems'
4
- require 'rake/gempackagetask'
5
- require 'rake/testtask'
6
- begin
7
- require 'rdoc/task'
8
- rescue LoadError
9
- puts "\nIt looks like you're using an old version of RDoc, but FakeWeb requires a newer one."
10
- puts "You can try upgrading with `sudo gem install rdoc`.\n\n"
11
- raise
12
- end
13
-
14
- task :default => :test
15
-
16
- desc "Run All Tests"
17
- Rake::TestTask.new :test do |test|
18
- test.test_files = ["test/**/*.rb"]
19
- test.verbose = false
20
- end
21
-
22
- desc "Generate Documentation"
23
- RDoc::Task.new do |rdoc|
24
- rdoc.main = "README.rdoc"
25
- rdoc.rdoc_dir = "doc"
26
- rdoc.rdoc_files.include("README.rdoc", "CHANGELOG", "LICENSE.txt", "lib/*.rb")
27
- rdoc.title = "FakeWeb API Documentation"
28
- rdoc.options << '--line-numbers' << '--charset' << 'utf-8'
29
- end
30
-
31
- desc %{Update ".manifest" with the latest list of project filenames. Respect\
32
- .gitignore by excluding everything that git ignores. Update `files` and\
33
- `test_files` arrays in "*.gemspec" file if it's present.}
34
- task :manifest do
35
- list = Dir['**/*'].sort
36
- spec_file = Dir['*.gemspec'].first
37
- list -= [spec_file] if spec_file
38
-
39
- File.read('.gitignore').each_line do |glob|
40
- glob = glob.chomp.sub(/^\//, '')
41
- list -= Dir[glob]
42
- list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
43
- puts "excluding #{glob}"
44
- end
45
-
46
- if spec_file
47
- spec = File.read spec_file
48
- spec.gsub!(/^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx) do
49
- assignment = $1
50
- bunch = $2 ? list.grep(/^test\//) : list
51
- '%s%%w(%s)' % [assignment, bunch.join(' ')]
52
- end
53
-
54
- File.open(spec_file, 'w') {|f| f << spec }
55
- end
56
- File.open('.manifest', 'w') {|f| f << list.join("\n") }
57
- end
58
-
59
- if RUBY_PLATFORM =~ /java/
60
- puts "rcov support disabled (running under JRuby)."
61
- elsif RUBY_VERSION =~ /^1\.9/
62
- puts "rcov support disabled (running under Ruby 1.9)"
63
- else
64
- require 'rcov/rcovtask'
65
- Rcov::RcovTask.new do |t|
66
- t.test_files = FileList['test/**/test*.rb']
67
- t.rcov_opts << "--sort coverage"
68
- t.rcov_opts << "--exclude gems"
69
- end
70
- end
71
-
72
- spec = eval(File.read(File.join(File.dirname(__FILE__), "fakeweb.gemspec")))
73
- Rake::GemPackageTask.new(spec) do |pkg|
74
- pkg.need_tar_gz = true
75
- pkg.need_zip = true
76
- end
@@ -1,172 +0,0 @@
1
- require 'singleton'
2
-
3
- require 'fake_web/ext/net_http'
4
- require 'fake_web/registry'
5
- require 'fake_web/response'
6
- require 'fake_web/responder'
7
- require 'fake_web/stub_socket'
8
- require 'fake_web/utility'
9
-
10
- module FakeWeb
11
-
12
- # Resets the FakeWeb Registry. This will force all subsequent web requests to
13
- # behave as real requests.
14
- def self.clean_registry
15
- Registry.instance.clean_registry
16
- end
17
-
18
- # Enables or disables real HTTP connections for requests that don't match
19
- # registered URIs.
20
- #
21
- # If you set <tt>FakeWeb.allow_net_connect = false</tt> and subsequently try
22
- # to make a request to a URI you haven't registered with #register_uri, a
23
- # NetConnectNotAllowedError will be raised. This is handy when you want to
24
- # make sure your tests are self-contained, or want to catch the scenario
25
- # when a URI is changed in implementation code without a corresponding test
26
- # change.
27
- #
28
- # When <tt>FakeWeb.allow_net_connect = true</tt> (the default), requests to
29
- # URIs not stubbed with FakeWeb are passed through to Net::HTTP.
30
- def self.allow_net_connect=(allowed)
31
- @allow_net_connect = allowed
32
- end
33
-
34
- # Enable pass-through to Net::HTTP by default.
35
- self.allow_net_connect = true
36
-
37
- # Returns +true+ if requests to URIs not registered with FakeWeb are passed
38
- # through to Net::HTTP for normal processing (the default). Returns +false+
39
- # if an exception is raised for these requests.
40
- def self.allow_net_connect?
41
- @allow_net_connect
42
- end
43
-
44
- # This exception is raised if you set <tt>FakeWeb.allow_net_connect =
45
- # false</tt> and subsequently try to make a request to a URI you haven't
46
- # stubbed.
47
- class NetConnectNotAllowedError < StandardError; end;
48
-
49
- # This exception is raised if a Net::HTTP request matches more than one of
50
- # the regular expression-based stubs you've registered. To fix the problem,
51
- # disambiguate the regular expressions by making them more specific.
52
- class MultipleMatchingRegexpsError < StandardError; end;
53
-
54
- # call-seq:
55
- # FakeWeb.register_uri(method, uri, options)
56
- #
57
- # Register requests using the HTTP method specified by the symbol +method+
58
- # for +uri+ to be handled according to +options+. If you specify the method
59
- # <tt>:any</tt>, the response will be reigstered for any request for +uri+.
60
- # +uri+ can be a +String+, +URI+, or +Regexp+ object. +options+ must be either
61
- # a +Hash+ or an +Array+ of +Hashes+ (see below), which must contain one of
62
- # these two keys:
63
- #
64
- # <tt>:body</tt>::
65
- # A string which is used as the body of the response. If the string refers
66
- # to a valid filesystem path, the contents of that file will be read and used
67
- # as the body of the response instead. (This used to be two options,
68
- # <tt>:string</tt> and <tt>:file</tt>, respectively. These are now deprecated.)
69
- # <tt>:response</tt>::
70
- # Either an <tt>Net::HTTPResponse</tt>, an +IO+, or a +String+ which is used
71
- # as the full response for the request.
72
- #
73
- # The easier way by far is to pass the <tt>:response</tt> option to
74
- # +register_uri+ as a +String+ or an (open for reads) +IO+ object which
75
- # will be used as the complete HTTP response, including headers and body.
76
- # If the string points to a readable file, this file will be used as the
77
- # content for the request.
78
- #
79
- # To obtain a complete response document, you can use the +curl+ command,
80
- # like so:
81
- #
82
- # curl -i http://www.example.com/ > response_for_www.example.com
83
- #
84
- # which can then be used in your test environment like so:
85
- #
86
- # FakeWeb.register_uri(:get, 'http://www.example.com/', :response => 'response_for_www.example.com')
87
- #
88
- # See the <tt>Net::HTTPResponse</tt>
89
- # documentation[http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTPResponse.html]
90
- # for more information on creating custom response objects.
91
- #
92
- # +options+ may also be an +Array+ containing a list of the above-described
93
- # +Hash+. In this case, FakeWeb will rotate through each provided response,
94
- # you may optionally provide:
95
- #
96
- # <tt>:times</tt>::
97
- # The number of times this response will be used. Decremented by one each time it's called.
98
- # FakeWeb will use the final provided request indefinitely, regardless of its :times parameter.
99
- #
100
- # Two optional arguments are also accepted:
101
- #
102
- # <tt>:status</tt>::
103
- # Passing <tt>:status</tt> as a two-value array will set the response code
104
- # and message. The defaults are <tt>200</tt> and <tt>OK</tt>, respectively.
105
- # Example:
106
- # FakeWeb.register_uri("http://www.example.com/", :body => "Go away!", :status => [404, "Not Found"])
107
- # <tt>:exception</tt>::
108
- # The argument passed via <tt>:exception</tt> will be raised when the
109
- # specified URL is requested. Any +Exception+ class is valid. Example:
110
- # FakeWeb.register_uri('http://www.example.com/', :exception => Net::HTTPError)
111
- #
112
- # If you're using the <tt>:body</tt> response type, you can pass additional
113
- # options to specify the HTTP headers to be used in the response. Example:
114
- #
115
- # FakeWeb.register_uri(:get, "http://example.com/index.txt", :body => "Hello", :content_type => "text/plain")
116
- def self.register_uri(*args)
117
- case args.length
118
- when 3
119
- Registry.instance.register_uri(*args)
120
- when 2
121
- print_missing_http_method_deprecation_warning(*args)
122
- Registry.instance.register_uri(:any, *args)
123
- else
124
- raise ArgumentError.new("wrong number of arguments (#{args.length} for 3)")
125
- end
126
- end
127
-
128
- # call-seq:
129
- # FakeWeb.response_for(method, uri)
130
- #
131
- # Returns the faked Net::HTTPResponse object associated with +method+ and +uri+.
132
- def self.response_for(*args, &block) #:nodoc: :yields: response
133
- case args.length
134
- when 2
135
- Registry.instance.response_for(*args, &block)
136
- when 1
137
- print_missing_http_method_deprecation_warning(*args)
138
- Registry.instance.response_for(:any, *args, &block)
139
- else
140
- raise ArgumentError.new("wrong number of arguments (#{args.length} for 2)")
141
- end
142
- end
143
-
144
- # call-seq:
145
- # FakeWeb.registered_uri?(method, uri)
146
- #
147
- # Returns true if a +method+ request for +uri+ is registered with FakeWeb.
148
- # Specify a method of <tt>:any</tt> to check for against all HTTP methods.
149
- def self.registered_uri?(*args)
150
- case args.length
151
- when 2
152
- Registry.instance.registered_uri?(*args)
153
- when 1
154
- print_missing_http_method_deprecation_warning(*args)
155
- Registry.instance.registered_uri?(:any, *args)
156
- else
157
- raise ArgumentError.new("wrong number of arguments (#{args.length} for 2)")
158
- end
159
- end
160
-
161
- private
162
-
163
- def self.print_missing_http_method_deprecation_warning(*args)
164
- method = caller.first.match(/`(.*?)'/)[1]
165
- new_args = args.map { |a| a.inspect }.unshift(":any")
166
- new_args.last.gsub!(/^\{|\}$/, "").gsub!("=>", " => ") if args.last.is_a?(Hash)
167
- $stderr.puts
168
- $stderr.puts "Deprecation warning: FakeWeb requires an HTTP method argument (or use :any). Try this:"
169
- $stderr.puts " FakeWeb.#{method}(#{new_args.join(', ')})"
170
- $stderr.puts "Called at #{caller[1]}"
171
- end
172
- end
@@ -1,71 +0,0 @@
1
- require 'net/http'
2
- require 'net/https'
3
- require 'stringio'
4
-
5
- module Net #:nodoc: all
6
-
7
- class BufferedIO
8
- alias initialize_without_fakeweb initialize
9
- def initialize(io, debug_output = nil)
10
- @read_timeout = 60
11
- @rbuf = ''
12
- @debug_output = debug_output
13
-
14
- @io = case io
15
- when Socket, OpenSSL::SSL::SSLSocket, IO
16
- io
17
- when String
18
- if !io.include?("\0") && File.exists?(io) && !File.directory?(io)
19
- File.open(io, "r")
20
- else
21
- StringIO.new(io)
22
- end
23
- end
24
- raise "Unable to create local socket" unless @io
25
- end
26
- end
27
-
28
- class HTTP
29
- class << self
30
- alias socket_type_without_fakeweb socket_type
31
- def socket_type
32
- FakeWeb::StubSocket
33
- end
34
- end
35
-
36
- alias request_without_fakeweb request
37
- def request(request, body = nil, &block)
38
- protocol = use_ssl? ? "https" : "http"
39
-
40
- path = request.path
41
- path = URI.parse(request.path).request_uri if request.path =~ /^http/
42
-
43
- if request["authorization"] =~ /^Basic /
44
- userinfo = FakeWeb::Utility.decode_userinfo_from_header(request["authorization"])
45
- userinfo = FakeWeb::Utility.encode_unsafe_chars_in_userinfo(userinfo) + "@"
46
- else
47
- userinfo = ""
48
- end
49
-
50
- uri = "#{protocol}://#{userinfo}#{self.address}:#{self.port}#{path}"
51
- method = request.method.downcase.to_sym
52
-
53
- if FakeWeb.registered_uri?(method, uri)
54
- @socket = Net::HTTP.socket_type.new
55
- FakeWeb.response_for(method, uri, &block)
56
- elsif FakeWeb.allow_net_connect?
57
- connect_without_fakeweb
58
- request_without_fakeweb(request, body, &block)
59
- else
60
- uri = FakeWeb::Utility.strip_default_port_from_uri(uri)
61
- raise FakeWeb::NetConnectNotAllowedError,
62
- "Real HTTP connections are disabled. Unregistered request: #{request.method} #{uri}"
63
- end
64
- end
65
-
66
- alias connect_without_fakeweb connect
67
- def connect
68
- end
69
- end
70
-
71
- end
@@ -1,103 +0,0 @@
1
- module FakeWeb
2
- class Registry #:nodoc:
3
- include Singleton
4
-
5
- attr_accessor :uri_map
6
-
7
- def initialize
8
- clean_registry
9
- end
10
-
11
- def clean_registry
12
- self.uri_map = Hash.new { |hash, key| hash[key] = {} }
13
- end
14
-
15
- def register_uri(method, uri, options)
16
- uri_map[normalize_uri(uri)][method] = [*[options]].flatten.collect do |option|
17
- FakeWeb::Responder.new(method, uri, option, option[:times])
18
- end
19
- end
20
-
21
- def registered_uri?(method, uri)
22
- normalized_uri = normalize_uri(uri)
23
- !responses_for(method, uri).empty?
24
- end
25
-
26
- def response_for(method, uri, &block)
27
- responses = responses_for(method, uri)
28
- return nil if responses.empty?
29
-
30
- next_response = responses.last
31
- responses.each do |response|
32
- if response.times and response.times > 0
33
- response.times -= 1
34
- next_response = response
35
- break
36
- end
37
- end
38
-
39
- next_response.response(&block)
40
- end
41
-
42
-
43
- private
44
-
45
- def responses_for(method, uri)
46
- uri = normalize_uri(uri)
47
-
48
- if uri_map[uri].has_key?(method)
49
- uri_map[uri][method]
50
- elsif uri_map[uri].has_key?(:any)
51
- uri_map[uri][:any]
52
- elsif uri_map_matches?(method, uri)
53
- uri_map_matches(method, uri)
54
- elsif uri_map_matches(:any, uri)
55
- uri_map_matches(:any, uri)
56
- else
57
- []
58
- end
59
- end
60
-
61
- def uri_map_matches?(method, uri)
62
- !uri_map_matches(method, uri).nil?
63
- end
64
-
65
- def uri_map_matches(method, uri)
66
- uri = normalize_uri(uri.to_s).to_s
67
- uri = Utility.strip_default_port_from_uri(uri)
68
-
69
- matches = uri_map.select { |registered_uri, method_hash|
70
- registered_uri.is_a?(Regexp) && uri.match(registered_uri) && method_hash.has_key?(method)
71
- }
72
-
73
- if matches.size > 1
74
- raise MultipleMatchingRegexpsError,
75
- "More than one regular expression matched this request: #{method.to_s.upcase} #{uri}"
76
- end
77
-
78
- matches.map { |_, method_hash| method_hash[method] }.first
79
- end
80
-
81
- def normalize_uri(uri)
82
- return uri if uri.is_a?(Regexp)
83
- normalized_uri =
84
- case uri
85
- when URI then uri
86
- when String
87
- uri = 'http://' + uri unless uri.match('^https?://')
88
- URI.parse(uri)
89
- end
90
- normalized_uri.query = sort_query_params(normalized_uri.query)
91
- normalized_uri.normalize
92
- end
93
-
94
- def sort_query_params(query)
95
- if query.nil? || query.empty?
96
- nil
97
- else
98
- query.split('&').sort.join('&')
99
- end
100
- end
101
-
102
- end
103
- end
@@ -1,113 +0,0 @@
1
- module FakeWeb
2
- class Responder #:nodoc:
3
-
4
- attr_accessor :method, :uri, :options, :times
5
- KNOWN_OPTIONS = [:body, :exception, :response, :status].freeze
6
-
7
- def initialize(method, uri, options, times)
8
- self.method = method
9
- self.uri = uri
10
- self.options = options
11
- self.times = times ? times : 1
12
-
13
- if options.has_key?(:file) || options.has_key?(:string)
14
- print_file_string_options_deprecation_warning
15
- options[:body] = options.delete(:file) || options.delete(:string)
16
- end
17
- end
18
-
19
- def response(&block)
20
- if has_baked_response?
21
- response = baked_response
22
- else
23
- code, msg = meta_information
24
- response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg)
25
- response.instance_variable_set(:@body, body)
26
- headers_extracted_from_options.each { |name, value| response[name] = value }
27
- end
28
-
29
- response.instance_variable_set(:@read, true)
30
- response.extend FakeWeb::Response
31
-
32
- optionally_raise(response)
33
-
34
- yield response if block_given?
35
-
36
- response
37
- end
38
-
39
- private
40
-
41
- def headers_extracted_from_options
42
- options.reject {|name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value|
43
- [name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value]
44
- }
45
- end
46
-
47
- def body
48
- return '' unless options.has_key?(:body)
49
-
50
- if !options[:body].include?("\0") && File.exists?(options[:body]) && !File.directory?(options[:body])
51
- File.read(options[:body])
52
- else
53
- options[:body]
54
- end
55
- end
56
-
57
- def baked_response
58
- resp = case options[:response]
59
- when Net::HTTPResponse then options[:response]
60
- when String
61
- socket = Net::BufferedIO.new(options[:response])
62
- r = Net::HTTPResponse.read_new(socket)
63
-
64
- # Store the oiriginal transfer-encoding
65
- saved_transfer_encoding = r.instance_eval {
66
- @header['transfer-encoding'] if @header.key?('transfer-encoding')
67
- }
68
-
69
- # read the body of response.
70
- r.instance_eval { @header['transfer-encoding'] = nil }
71
- r.reading_body(socket, true) {}
72
-
73
- # Delete the transfer-encoding key from r.@header if there wasn't one,
74
- # else restore the saved_transfer_encoding.
75
- if saved_transfer_encoding.nil?
76
- r.instance_eval { @header.delete('transfer-encoding') }
77
- else
78
- r.instance_eval { @header['transfer-encoding'] = saved_transfer_encoding }
79
- end
80
- r
81
- else raise StandardError, "Handler unimplemented for response #{options[:response]}"
82
- end
83
- end
84
-
85
- def has_baked_response?
86
- options.has_key?(:response)
87
- end
88
-
89
- def optionally_raise(response)
90
- return unless options.has_key?(:exception)
91
-
92
- case options[:exception].to_s
93
- when "Net::HTTPError", "OpenURI::HTTPError"
94
- raise options[:exception].new('Exception from FakeWeb', response)
95
- else
96
- raise options[:exception].new('Exception from FakeWeb')
97
- end
98
- end
99
-
100
- def meta_information
101
- options.has_key?(:status) ? options[:status] : [200, 'OK']
102
- end
103
-
104
- def print_file_string_options_deprecation_warning
105
- which = options.has_key?(:file) ? :file : :string
106
- $stderr.puts
107
- $stderr.puts "Deprecation warning: FakeWeb's :#{which} option has been renamed to :body."
108
- $stderr.puts "Just replace :#{which} with :body in your FakeWeb.register_uri calls."
109
- $stderr.puts "Called at #{caller[6]}"
110
- end
111
-
112
- end
113
- end