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,58 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestFakeWebOpenURI < Test::Unit::TestCase
4
-
5
- def test_content_for_registered_uri
6
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
7
- assert_equal 'test example content', FakeWeb.response_for(:get, 'http://mock/test_example.txt').body
8
- end
9
-
10
- def test_mock_open
11
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
12
- assert_equal 'test example content', open('http://mock/test_example.txt').read
13
- end
14
-
15
- def test_mock_open_with_string_as_registered_uri
16
- FakeWeb.register_uri(:get, 'http://mock/test_string.txt', :body => 'foo')
17
- assert_equal 'foo', open('http://mock/test_string.txt').string
18
- end
19
-
20
- def test_real_open
21
- FakeWeb.allow_net_connect = true
22
- setup_expectations_for_real_apple_hot_news_request
23
- resp = open('http://images.apple.com/main/rss/hotnews/hotnews.rss')
24
- assert_equal "200", resp.status.first
25
- body = resp.read
26
- assert body.include?('Apple')
27
- assert body.include?('News')
28
- end
29
-
30
- def test_mock_open_that_raises_exception
31
- FakeWeb.register_uri(:get, 'http://mock/raising_exception.txt', :exception => StandardError)
32
- assert_raises(StandardError) do
33
- open('http://mock/raising_exception.txt')
34
- end
35
- end
36
-
37
- def test_mock_open_that_raises_an_http_error
38
- FakeWeb.register_uri(:get, 'http://mock/raising_exception.txt', :exception => OpenURI::HTTPError)
39
- assert_raises(OpenURI::HTTPError) do
40
- open('http://mock/raising_exception.txt')
41
- end
42
- end
43
-
44
- def test_mock_open_that_raises_an_http_error_with_a_specific_status
45
- FakeWeb.register_uri(:get, 'http://mock/raising_exception.txt', :exception => OpenURI::HTTPError, :status => ['123', 'jodel'])
46
- exception = assert_raises(OpenURI::HTTPError) do
47
- open('http://mock/raising_exception.txt')
48
- end
49
- assert_equal '123', exception.io.code
50
- assert_equal 'jodel', exception.io.message
51
- end
52
-
53
- def test_mock_open_with_block
54
- FakeWeb.register_uri(:get, 'http://mock/test_example.txt', :body => File.dirname(__FILE__) + '/fixtures/test_example.txt')
55
- body = open('http://mock/test_example.txt') { |f| f.readlines }
56
- assert_equal 'test example content', body.first
57
- end
58
- end
@@ -1,74 +0,0 @@
1
- $:.unshift "#{File.dirname(__FILE__)}/../lib"
2
-
3
- require 'test/unit'
4
- require 'open-uri'
5
- require 'fake_web'
6
- require 'rubygems'
7
- require 'mocha'
8
-
9
-
10
- # Give all tests a common setup and teardown that prevents shared state
11
- class Test::Unit::TestCase
12
- def setup
13
- FakeWeb.clean_registry
14
- @original_allow_net_connect = FakeWeb.allow_net_connect?
15
- FakeWeb.allow_net_connect = false
16
- end
17
-
18
- def teardown
19
- FakeWeb.allow_net_connect = @original_allow_net_connect
20
- end
21
- end
22
-
23
-
24
- module FakeWebTestHelper
25
-
26
- def capture_stderr
27
- $stderr = StringIO.new
28
- yield
29
- $stderr.rewind && $stderr.read
30
- ensure
31
- $stderr = STDERR
32
- end
33
-
34
- # Sets several expectations (using Mocha) that a real HTTP request makes it
35
- # past FakeWeb to the socket layer. You can use this when you need to check
36
- # that a request isn't handled by FakeWeb.
37
- def setup_expectations_for_real_request(options = {})
38
- # Socket handling
39
- if options[:port] == 443
40
- socket = mock("SSLSocket")
41
- OpenSSL::SSL::SSLSocket.expects(:===).with(socket).returns(true).at_least_once
42
- OpenSSL::SSL::SSLSocket.expects(:new).with(socket, instance_of(OpenSSL::SSL::SSLContext)).returns(socket).at_least_once
43
- socket.stubs(:sync_close=).returns(true)
44
- socket.expects(:connect).with().at_least_once
45
- else
46
- socket = mock("TCPSocket")
47
- Socket.expects(:===).with(socket).returns(true)
48
- end
49
-
50
- TCPSocket.expects(:open).with(options[:host], options[:port]).returns(socket).at_least_once
51
- socket.stubs(:closed?).returns(false)
52
- socket.stubs(:close).returns(true)
53
-
54
- # Request/response handling
55
- request_parts = ["#{options[:method]} #{options[:path]} HTTP/1.1", "Host: #{options[:host]}"]
56
- socket.expects(:write).with(all_of(includes(request_parts[0]), includes(request_parts[1]))).returns(100)
57
-
58
- socket.expects(:sysread).at_least_once.returns("HTTP/1.1 #{options[:response_code]} #{options[:response_message]}\nContent-Length: #{options[:response_body].length}\n\n#{options[:response_body]}").then.raises(EOFError)
59
- end
60
-
61
-
62
- # A helper that calls #setup_expectations_for_real_request for you, using
63
- # defaults for our commonly used test request to images.apple.com.
64
- def setup_expectations_for_real_apple_hot_news_request(options = {})
65
- defaults = { :host => "images.apple.com", :port => 80, :method => "GET",
66
- :path => "/main/rss/hotnews/hotnews.rss",
67
- :response_code => 200, :response_message => "OK",
68
- :response_body => "<title>Apple Hot News</title>" }
69
- setup_expectations_for_real_request(defaults.merge(options))
70
- end
71
-
72
- end
73
-
74
- Test::Unit::TestCase.send(:include, FakeWebTestHelper)
@@ -1,25 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestMissingOpenURI < Test::Unit::TestCase
4
-
5
- def setup
6
- super
7
- @saved_open_uri = OpenURI
8
- Object.send(:remove_const, :OpenURI)
9
- end
10
-
11
- def teardown
12
- super
13
- Object.const_set(:OpenURI, @saved_open_uri)
14
- end
15
-
16
-
17
- def test_register_using_exception_without_open_uri
18
- # regression test for Responder needing OpenURI::HTTPError to be defined
19
- FakeWeb.register_uri(:get, "http://example.com/", :exception => StandardError)
20
- assert_raises(StandardError) do
21
- Net::HTTP.start("example.com") { |http| http.get("/") }
22
- end
23
- end
24
-
25
- end
@@ -1,51 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestPrecedence < Test::Unit::TestCase
4
-
5
- def test_matching_get_strings_have_precedence_over_matching_get_regexes
6
- FakeWeb.register_uri(:get, "http://example.com/test", :body => "string")
7
- FakeWeb.register_uri(:get, %r|http://example\.com/test|, :body => "regex")
8
- response = Net::HTTP.start("example.com") { |query| query.get('/test') }
9
- assert_equal "string", response.body
10
- end
11
-
12
- def test_matching_any_strings_have_precedence_over_matching_any_regexes
13
- FakeWeb.register_uri(:any, "http://example.com/test", :body => "string")
14
- FakeWeb.register_uri(:any, %r|http://example\.com/test|, :body => "regex")
15
- response = Net::HTTP.start("example.com") { |query| query.get('/test') }
16
- assert_equal "string", response.body
17
- end
18
-
19
- def test_matching_get_strings_have_precedence_over_matching_any_strings
20
- FakeWeb.register_uri(:get, "http://example.com/test", :body => "get method")
21
- FakeWeb.register_uri(:any, "http://example.com/test", :body => "any method")
22
- response = Net::HTTP.start("example.com") { |query| query.get('/test') }
23
- assert_equal "get method", response.body
24
-
25
- # registration order should not matter
26
- FakeWeb.register_uri(:any, "http://example.com/test2", :body => "any method")
27
- FakeWeb.register_uri(:get, "http://example.com/test2", :body => "get method")
28
- response = Net::HTTP.start("example.com") { |query| query.get('/test2') }
29
- assert_equal "get method", response.body
30
- end
31
-
32
- def test_matching_any_strings_have_precedence_over_matching_get_regexes
33
- FakeWeb.register_uri(:any, "http://example.com/test", :body => "any string")
34
- FakeWeb.register_uri(:get, %r|http://example\.com/test|, :body => "get regex")
35
- response = Net::HTTP.start("example.com") { |query| query.get('/test') }
36
- assert_equal "any string", response.body
37
- end
38
-
39
- def test_registered_strings_and_uris_are_equivalent_so_second_takes_precedence
40
- FakeWeb.register_uri(:get, "http://example.com/test", :body => "string")
41
- FakeWeb.register_uri(:get, URI.parse("http://example.com/test"), :body => "uri")
42
- response = Net::HTTP.start("example.com") { |query| query.get('/test') }
43
- assert_equal "uri", response.body
44
-
45
- FakeWeb.register_uri(:get, URI.parse("http://example.com/test2"), :body => "uri")
46
- FakeWeb.register_uri(:get, "http://example.com/test2", :body => "string")
47
- response = Net::HTTP.start("example.com") { |query| query.get('/test2') }
48
- assert_equal "string", response.body
49
- end
50
-
51
- end
@@ -1,45 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestFakeWebQueryString < Test::Unit::TestCase
4
-
5
- def test_register_uri_string_with_query_params
6
- FakeWeb.register_uri(:get, 'http://example.com/?a=1&b=1', :body => 'foo')
7
- assert FakeWeb.registered_uri?(:get, 'http://example.com/?a=1&b=1')
8
-
9
- FakeWeb.register_uri(:post, URI.parse("http://example.org/?a=1&b=1"), :body => "foo")
10
- assert FakeWeb.registered_uri?(:post, "http://example.org/?a=1&b=1")
11
- end
12
-
13
- def test_register_uri_with_query_params_and_check_in_different_order
14
- FakeWeb.register_uri(:get, 'http://example.com/?a=1&b=1', :body => 'foo')
15
- assert FakeWeb.registered_uri?(:get, 'http://example.com/?b=1&a=1')
16
-
17
- FakeWeb.register_uri(:post, URI.parse('http://example.org/?a=1&b=1'), :body => 'foo')
18
- assert FakeWeb.registered_uri?(:post, 'http://example.org/?b=1&a=1')
19
- end
20
-
21
- def test_registered_uri_gets_recognized_with_empty_query_params
22
- FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
23
- assert FakeWeb.registered_uri?(:get, 'http://example.com/?')
24
-
25
- FakeWeb.register_uri(:post, URI.parse('http://example.org/'), :body => 'foo')
26
- assert FakeWeb.registered_uri?(:post, 'http://example.org/?')
27
- end
28
-
29
- def test_register_uri_with_empty_query_params_and_check_with_none
30
- FakeWeb.register_uri(:get, 'http://example.com/?', :body => 'foo')
31
- assert FakeWeb.registered_uri?(:get, 'http://example.com/')
32
-
33
- FakeWeb.register_uri(:post, URI.parse('http://example.org/?'), :body => 'foo')
34
- assert FakeWeb.registered_uri?(:post, 'http://example.org/')
35
- end
36
-
37
- def test_registry_sort_query_params
38
- assert_equal "a=1&b=2", FakeWeb::Registry.instance.send(:sort_query_params, "b=2&a=1")
39
- end
40
-
41
- def test_registry_sort_query_params_sorts_by_value_if_keys_collide
42
- assert_equal "a=1&a=2&b=2", FakeWeb::Registry.instance.send(:sort_query_params, "a=2&b=2&a=1")
43
- end
44
-
45
- end
@@ -1,103 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestRegexes < Test::Unit::TestCase
4
-
5
- def test_registered_uri_with_pattern
6
- FakeWeb.register_uri(:get, %r|http://example.com/test_example/\d+|, :body => "example")
7
- assert FakeWeb.registered_uri?(:get, "http://example.com/test_example/25")
8
- assert !FakeWeb.registered_uri?(:get, "http://example.com/test_example/abc")
9
- end
10
-
11
- def test_response_for_with_matching_registered_uri
12
- FakeWeb.register_uri(:get, %r|http://www.google.com|, :body => "Welcome to Google!")
13
- assert_equal "Welcome to Google!", FakeWeb.response_for(:get, "http://www.google.com").body
14
- end
15
-
16
- def test_response_for_with_matching_registered_uri_and_get_method_matching_to_any_method
17
- FakeWeb.register_uri(:any, %r|http://www.example.com|, :body => "example")
18
- assert_equal "example", FakeWeb.response_for(:get, "http://www.example.com").body
19
- end
20
-
21
- def test_registered_uri_with_authentication_and_pattern
22
- FakeWeb.register_uri(:get, %r|http://user:pass@mock/example\.\w+|i, :body => "example")
23
- assert FakeWeb.registered_uri?(:get, 'http://user:pass@mock/example.txt')
24
- end
25
-
26
- def test_registered_uri_with_authentication_and_pattern_handles_case_insensitivity
27
- FakeWeb.register_uri(:get, %r|http://user:pass@mock/example\.\w+|i, :body => "example")
28
- assert FakeWeb.registered_uri?(:get, 'http://uSeR:PAss@mock/example.txt')
29
- end
30
-
31
- def test_request_with_authentication_and_pattern_handles_case_insensitivity
32
- FakeWeb.register_uri(:get, %r|http://user:pass@mock/example\.\w+|i, :body => "example")
33
- http = Net::HTTP.new('mock', 80)
34
- req = Net::HTTP::Get.new('/example.txt')
35
- req.basic_auth 'uSeR', 'PAss'
36
- assert_equal "example", http.request(req).body
37
- end
38
-
39
- def test_requesting_a_uri_that_matches_two_registered_regexes_raises_an_error
40
- FakeWeb.register_uri(:get, %r|http://example\.com/|, :body => "first")
41
- FakeWeb.register_uri(:get, %r|http://example\.com/a|, :body => "second")
42
- assert_raise FakeWeb::MultipleMatchingRegexpsError do
43
- Net::HTTP.start("example.com") { |query| query.get('/a') }
44
- end
45
- end
46
-
47
- def test_requesting_a_uri_that_matches_two_registered_regexes_raises_an_error_including_request_info
48
- FakeWeb.register_uri(:get, %r|http://example\.com/|, :body => "first")
49
- FakeWeb.register_uri(:get, %r|http://example\.com/a|, :body => "second")
50
- begin
51
- Net::HTTP.start("example.com") { |query| query.get('/a') }
52
- rescue FakeWeb::MultipleMatchingRegexpsError => exception
53
- end
54
- assert exception.message.include?("GET http://example.com/a")
55
- end
56
-
57
- def test_registry_does_not_find_using_mismatched_protocols_or_ports_when_registered_with_both
58
- FakeWeb.register_uri(:get, %r|http://www.example.com:80|, :body => "example")
59
- assert !FakeWeb.registered_uri?(:get, "https://www.example.com:80")
60
- assert !FakeWeb.registered_uri?(:get, "http://www.example.com:443")
61
- end
62
-
63
- def test_registry_only_finds_using_default_port_when_registered_without_if_protocol_matches
64
- FakeWeb.register_uri(:get, %r|http://www.example.com/test|, :body => "example")
65
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:80/test")
66
- assert !FakeWeb.registered_uri?(:get, "http://www.example.com:443/test")
67
- assert !FakeWeb.registered_uri?(:get, "https://www.example.com:443/test")
68
- FakeWeb.register_uri(:get, %r|https://www.example.org/test|, :body => "example")
69
- assert FakeWeb.registered_uri?(:get, "https://www.example.org:443/test")
70
- assert !FakeWeb.registered_uri?(:get, "https://www.example.org:80/test")
71
- assert !FakeWeb.registered_uri?(:get, "http://www.example.org:80/test")
72
- end
73
-
74
- def test_registry_matches_using_mismatched_port_when_registered_without
75
- FakeWeb.register_uri(:get, %r|http://www.example.com|, :body => "example")
76
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:80")
77
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:443")
78
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:12345")
79
- assert !FakeWeb.registered_uri?(:get, "https://www.example.com:443")
80
- assert !FakeWeb.registered_uri?(:get, "https://www.example.com")
81
- end
82
-
83
- def test_registry_matches_using_any_protocol_and_port_when_registered_without_protocol_or_port
84
- FakeWeb.register_uri(:get, %r|www.example.com|, :body => "example")
85
- assert FakeWeb.registered_uri?(:get, "http://www.example.com")
86
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:80")
87
- assert FakeWeb.registered_uri?(:get, "http://www.example.com:443")
88
- assert FakeWeb.registered_uri?(:get, "https://www.example.com")
89
- assert FakeWeb.registered_uri?(:get, "https://www.example.com:80")
90
- assert FakeWeb.registered_uri?(:get, "https://www.example.com:443")
91
- end
92
-
93
- def test_registry_matches_with_query_params
94
- FakeWeb.register_uri(:get, %r[example.com/list\?(.*&|)important=1], :body => "example")
95
- assert FakeWeb.registered_uri?(:get, "http://example.com/list?hash=123&important=1&unimportant=2")
96
- assert FakeWeb.registered_uri?(:get, "http://example.com/list?hash=123&important=12&unimportant=2")
97
- assert FakeWeb.registered_uri?(:get, "http://example.com/list?important=1&unimportant=2")
98
- assert !FakeWeb.registered_uri?(:get, "http://example.com/list?important=2")
99
- assert !FakeWeb.registered_uri?(:get, "http://example.com/list?important=2&unimportant=1")
100
- assert !FakeWeb.registered_uri?(:get, "http://example.com/list?hash=123&important=2&unimportant=1")
101
- assert !FakeWeb.registered_uri?(:get, "http://example.com/list?notimportant=1&unimportant=1")
102
- end
103
- end
@@ -1,67 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestResponseHeaders < Test::Unit::TestCase
4
-
5
- def test_content_type_when_registering_with_string_and_content_type_header
6
- FakeWeb.register_uri(:get, "http://example.com/users.json", :body => '[{"username": "chrisk"}]', :content_type => "application/json")
7
- response = Net::HTTP.start("example.com") { |query| query.get("/users.json") }
8
- assert_equal '[{"username": "chrisk"}]', response.body
9
- assert_equal "application/json", response['Content-Type']
10
- end
11
-
12
- def test_content_type_when_registering_with_string_only
13
- FakeWeb.register_uri(:get, "http://example.com/users.json", :body => '[{"username": "chrisk"}]')
14
- response = Net::HTTP.start("example.com") { |query| query.get("/users.json") }
15
- assert_equal '[{"username": "chrisk"}]', response.body
16
- assert_nil response['Content-Type']
17
- end
18
-
19
- def test_cookies_when_registering_with_file_and_set_cookie_header
20
- FakeWeb.register_uri(:get, "http://example.com/", :body => File.dirname(__FILE__) + '/fixtures/test_example.txt',
21
- :set_cookie => "user_id=1; example=yes")
22
- response = Net::HTTP.start("example.com") { |query| query.get("/") }
23
- assert_equal "test example content", response.body
24
- assert_equal "user_id=1; example=yes", response['Set-Cookie']
25
- end
26
-
27
- def test_registering_with_baked_response_ignores_header_options
28
- fake_response = Net::HTTPOK.new('1.1', '200', 'OK')
29
- fake_response["Server"] = "Apache/1.3.27 (Unix)"
30
- FakeWeb.register_uri(:get, "http://example.com/", :response => fake_response,
31
- :server => "FakeWeb/1.2.3 (Ruby)")
32
- response = Net::HTTP.start("example.com") { |query| query.get("/") }
33
- assert_equal "200", response.code
34
- assert_equal "OK", response.message
35
- assert_equal "Apache/1.3.27 (Unix)", response["Server"]
36
- end
37
-
38
- def test_headers_are_rotated_when_registering_with_response_rotation
39
- FakeWeb.register_uri(:get, "http://example.com",
40
- [{:body => 'test1', :expires => "Thu, 14 Jun 2009 16:00:00 GMT",
41
- :content_type => "text/plain"},
42
- {:body => 'test2', :expires => "Thu, 14 Jun 2009 16:00:01 GMT"}])
43
-
44
- first_response = second_response = nil
45
- Net::HTTP.start("example.com") do |query|
46
- first_response = query.get("/")
47
- second_response = query.get("/")
48
- end
49
- assert_equal 'test1', first_response.body
50
- assert_equal "Thu, 14 Jun 2009 16:00:00 GMT", first_response['Expires']
51
- assert_equal "text/plain", first_response['Content-Type']
52
- assert_equal 'test2', second_response.body
53
- assert_equal "Thu, 14 Jun 2009 16:00:01 GMT", second_response['Expires']
54
- assert_nil second_response['Content-Type']
55
- end
56
-
57
- def test_registering_with_status_option_and_response_headers
58
- FakeWeb.register_uri(:get, "http://example.com", :status => ["301", "Moved Permanently"],
59
- :location => "http://www.example.com")
60
-
61
- response = Net::HTTP.start("example.com") { |query| query.get("/") }
62
- assert_equal "301", response.code
63
- assert_equal "Moved Permanently", response.message
64
- assert_equal "http://www.example.com", response["Location"]
65
- end
66
-
67
- end
@@ -1,53 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class TestFakeWebTrailingSlashes < Test::Unit::TestCase
4
-
5
- def test_registering_root_without_slash_and_ask_predicate_method_with_slash
6
- FakeWeb.register_uri(:get, "http://www.example.com", :body => "root")
7
- assert FakeWeb.registered_uri?(:get, "http://www.example.com/")
8
- end
9
-
10
- def test_registering_root_without_slash_and_request
11
- FakeWeb.register_uri(:get, "http://www.example.com", :body => "root")
12
- response = Net::HTTP.start("www.example.com") { |query| query.get('/') }
13
- assert_equal "root", response.body
14
- end
15
-
16
- def test_registering_root_with_slash_and_ask_predicate_method_without_slash
17
- FakeWeb.register_uri(:get, "http://www.example.com/", :body => "root")
18
- assert FakeWeb.registered_uri?(:get, "http://www.example.com")
19
- end
20
-
21
- def test_registering_root_with_slash_and_request
22
- FakeWeb.register_uri(:get, "http://www.example.com/", :body => "root")
23
- response = Net::HTTP.start("www.example.com") { |query| query.get('/') }
24
- assert_equal "root", response.body
25
- end
26
-
27
- def test_registering_path_without_slash_and_ask_predicate_method_with_slash
28
- FakeWeb.register_uri(:get, "http://www.example.com/users", :body => "User list")
29
- assert !FakeWeb.registered_uri?(:get, "http://www.example.com/users/")
30
- end
31
-
32
- def test_registering_path_without_slash_and_request_with_slash
33
- FakeWeb.allow_net_connect = false
34
- FakeWeb.register_uri(:get, "http://www.example.com/users", :body => "User list")
35
- assert_raise FakeWeb::NetConnectNotAllowedError do
36
- response = Net::HTTP.start("www.example.com") { |query| query.get('/users/') }
37
- end
38
- end
39
-
40
- def test_registering_path_with_slash_and_ask_predicate_method_without_slash
41
- FakeWeb.register_uri(:get, "http://www.example.com/users/", :body => "User list")
42
- assert !FakeWeb.registered_uri?(:get, "http://www.example.com/users")
43
- end
44
-
45
- def test_registering_path_with_slash_and_request_without_slash
46
- FakeWeb.allow_net_connect = false
47
- FakeWeb.register_uri(:get, "http://www.example.com/users/", :body => "User list")
48
- assert_raise FakeWeb::NetConnectNotAllowedError do
49
- response = Net::HTTP.start("www.example.com") { |query| query.get('/users') }
50
- end
51
- end
52
-
53
- end