FakeWeb 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/CHANGELOG +8 -0
  2. data/Rakefile +1 -1
  3. data/lib/fake_net_http.rb +11 -5
  4. data/lib/fake_web.rb +1 -41
  5. metadata +32 -25
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ fakeweb (1.0.1)
2
+
3
+ [ Blaine Cook ]
4
+ * update code to correspond to ruby 1.8.4
5
+ * breaks compatibility with ruby 1.8.2
6
+
7
+ -- Blaine Cook <romeda@gmail.com> Tue, 23 May 2006 16:13:26 -0800
8
+
1
9
  fakeweb (1.0.0)
2
10
 
3
11
  [ Blaine Cook ]
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ require 'rcov/rcovtask'
24
24
 
25
25
  spec = Gem::Specification.new do |s|
26
26
  s.name = "FakeWeb"
27
- s.version = "1.0.0"
27
+ s.version = "1.1.0"
28
28
  s.author = "Blaine Cook"
29
29
  s.email = "romeda@gmail.com"
30
30
  s.homepage = "http://fakeweb.rubyforge.org/"
@@ -17,19 +17,21 @@
17
17
 
18
18
  require 'net/http'
19
19
  require 'net/https'
20
+ require 'rubygems'
21
+ require 'breakpoint'
20
22
  require 'stringio'
21
23
 
22
24
  module Net #:nodoc:
23
25
 
24
- class LocalMessageIO < Net::InternetMessageIO #:nodoc:
26
+ class BufferedIO #:nodoc:
25
27
  def initialize( io, debug_output = nil )
26
28
  @debug_output = debug_output
27
- @socket = case io
29
+ @io = case io
28
30
  when Socket, IO: io
29
31
  when String
30
32
  File.exists?(io) ? File.open(io, "r") : StringIO.new(io)
31
33
  end
32
- raise "Unable to create local socket" unless @socket
34
+ raise "Unable to create local socket" unless @io
33
35
  connect
34
36
  end
35
37
 
@@ -38,7 +40,7 @@ module Net #:nodoc:
38
40
  end
39
41
 
40
42
  def rbuf_fill
41
- @rbuf << @socket.sysread(1024)
43
+ @rbuf << @io.sysread(1024)
42
44
  end
43
45
  end
44
46
 
@@ -49,7 +51,7 @@ module Net #:nodoc:
49
51
  end
50
52
 
51
53
  alias :original_net_http_request :request
52
- alias :original_net_http_do_start :do_start
54
+ alias :original_net_http_connect :connect
53
55
 
54
56
  def request(req, body = nil, &block)
55
57
  prot = use_ssl ? "https" : "http"
@@ -58,8 +60,12 @@ module Net #:nodoc:
58
60
  @socket = Net::HTTP.socket_type.new
59
61
  return FakeWeb.response_for(uri, &block)
60
62
  else
63
+ original_net_http_connect
61
64
  return original_net_http_request(req, body, &block)
62
65
  end
63
66
  end
67
+
68
+ def connect
69
+ end
64
70
  end
65
71
  end
@@ -83,11 +83,6 @@ module FakeWeb
83
83
  # Checks for presence of +uri+ in the +FakeWeb+ registry.
84
84
  def FakeWeb.registered_uri?(uri); FakeWeb::Registry.instance.registered_uri?(uri); end
85
85
 
86
- def FakeWeb.registered_host?(*args) #:nodoc:
87
- FakeWeb::Registry.instance.registered_host?(*args)
88
- end
89
-
90
-
91
86
  class Registry #:nodoc:
92
87
  include Singleton
93
88
 
@@ -109,13 +104,6 @@ module FakeWeb
109
104
  uri_map.has_key?(normalize_uri(uri))
110
105
  end
111
106
 
112
- def registered_host?(host)
113
- uri_map.each_key do |uri|
114
- return true if uri.host == host
115
- end
116
- false
117
- end
118
-
119
107
  def registered_uri(uri)
120
108
  uri = normalize_uri(uri)
121
109
  return uri_map[uri] if registered_uri?(uri)
@@ -194,7 +182,7 @@ module FakeWeb
194
182
  resp = case options[:response]
195
183
  when Net::HTTPResponse: options[:response]
196
184
  when String
197
- socket = Net::LocalMessageIO.new(options[:response])
185
+ socket = Net::BufferedIO.new(options[:response])
198
186
  r = Net::HTTPResponse.read_new(socket)
199
187
  r.instance_eval { @header['transfer-encoding'] = nil }
200
188
  r.reading_body(socket, true) {}
@@ -226,18 +214,6 @@ module FakeWeb
226
214
 
227
215
  class SocketDelegator #:nodoc:
228
216
 
229
- def self.delegate_to
230
- Net::InternetMessageIO
231
- end
232
-
233
- def self.open(*args)
234
- if FakeWeb.registered_host?(args[0])
235
- new().open(*args)
236
- else
237
- delegate_to.open(*args)
238
- end
239
- end
240
-
241
217
  def initialize(delegate=nil)
242
218
  @delegate = nil
243
219
  end
@@ -247,26 +223,10 @@ module FakeWeb
247
223
  return self.send("my_#{method}", *args, &block)
248
224
  end
249
225
 
250
- def my_open(*args)
251
- @open_args = args
252
- @closed = false
253
- return self
254
- end
255
-
256
226
  def my_closed?
257
227
  @closed ||= true
258
228
  end
259
229
 
260
- def my_reopen(*args)
261
- @reopen_args = args
262
- @close = false
263
- end
264
-
265
- def my_write(*args)
266
- @delegate = self.class.delegate_to.open(*@open_args)
267
- return @delegate.write(*args)
268
- end
269
-
270
230
  def my_readuntil(*args)
271
231
  end
272
232
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: FakeWeb
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2006-05-23
6
+ version: 1.1.0
7
+ date: 2006-05-23 00:00:00 -07:00
8
8
  summary: A test helper that makes it simple to test HTTP interaction
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: romeda@gmail.com
12
12
  homepage: http://fakeweb.rubyforge.org/
13
13
  rubyforge_project: fakeweb
@@ -18,34 +18,41 @@ bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
27
28
  authors:
28
- - Blaine Cook
29
+ - Blaine Cook
29
30
  files:
30
- - test/fixtures
31
- - test/unit
32
- - test/fixtures/test_example.txt
33
- - test/fixtures/test_request
34
- - test/unit/test_examples.rb
35
- - test/unit/test_fake_web.rb
36
- - test/unit/test_fake_web_open_uri.rb
37
- - lib/fake_net_http.rb
38
- - lib/fake_web.rb
39
- - CHANGELOG
40
- - COPYING
41
- - Rakefile
42
- - README
31
+ - test/fixtures
32
+ - test/unit
33
+ - test/fixtures/test_example.txt
34
+ - test/fixtures/test_request
35
+ - test/unit/test_examples.rb
36
+ - test/unit/test_fake_web.rb
37
+ - test/unit/test_fake_web_open_uri.rb
38
+ - lib/fake_net_http.rb
39
+ - lib/fake_web.rb
40
+ - CHANGELOG
41
+ - COPYING
42
+ - Rakefile
43
+ - README
43
44
  test_files: []
45
+
44
46
  rdoc_options: []
47
+
45
48
  extra_rdoc_files:
46
- - README
47
- - COPYING
49
+ - README
50
+ - COPYING
48
51
  executables: []
52
+
49
53
  extensions: []
54
+
50
55
  requirements: []
51
- dependencies: []
56
+
57
+ dependencies: []
58
+