chrisk-fakeweb 1.1.2.6 → 1.1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,34 +1,18 @@
1
- # FakeWeb - Ruby Helper for Faking Web Requests
2
- # Copyright 2006 Blaine Cook <romeda@gmail.com>.
3
- #
4
- # FakeWeb is free software; you can redistribute it and/or modify
5
- # it under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation; either version 2 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # FakeWeb is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License
15
- # along with FakeWeb; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
-
18
1
  require File.join(File.dirname(__FILE__), "test_helper")
19
2
 
20
3
  class TestFakeWebOpenURI < Test::Unit::TestCase
21
4
 
22
5
  def setup
23
6
  FakeWeb.clean_registry
24
- FakeWeb.register_uri('http://mock/test_example.txt', :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
25
7
  end
26
8
 
27
9
  def test_content_for_registered_uri
10
+ FakeWeb.register_uri('http://mock/test_example.txt', :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
28
11
  assert_equal 'test example content', FakeWeb.response_for('http://mock/test_example.txt').body
29
12
  end
30
13
 
31
14
  def test_mock_open
15
+ FakeWeb.register_uri('http://mock/test_example.txt', :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
32
16
  assert_equal 'test example content', open('http://mock/test_example.txt').read
33
17
  end
34
18
 
@@ -70,6 +54,7 @@ class TestFakeWebOpenURI < Test::Unit::TestCase
70
54
  end
71
55
 
72
56
  def test_mock_open_with_block
57
+ FakeWeb.register_uri('http://mock/test_example.txt', :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
73
58
  open('http://mock/test_example.txt') do |f|
74
59
  assert 'test example content', f.readlines
75
60
  end
@@ -33,7 +33,7 @@ module FakeWebTestHelper
33
33
  socket.expects(:write).with(all_of(includes(request_parts[0]), includes(request_parts[1]))).returns(100)
34
34
 
35
35
  # TODO: handle long response bodies that use more than one #sysread call
36
- socket.expects(:sysread).with(1024).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)
36
+ 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)
37
37
  end
38
38
 
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrisk-fakeweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2.6
4
+ version: 1.1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blaine Cook
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-31 00:00:00 -08:00
12
+ date: 2009-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -21,20 +21,29 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - CHANGELOG
24
- - COPYING
24
+ - LICENSE.txt
25
25
  - README.rdoc
26
26
  files:
27
27
  - CHANGELOG
28
- - COPYING
28
+ - LICENSE.txt
29
29
  - README.rdoc
30
30
  - Rakefile
31
31
  - lib
32
- - lib/fake_net_http.rb
32
+ - lib/fake_web
33
33
  - lib/fake_web.rb
34
+ - lib/fake_web/ext
35
+ - lib/fake_web/ext/net_http.rb
36
+ - lib/fake_web/registry.rb
37
+ - lib/fake_web/responder.rb
38
+ - lib/fake_web/response.rb
39
+ - lib/fake_web/socket_delegator.rb
34
40
  - test
35
41
  - test/fixtures
42
+ - test/fixtures/google_response_from_curl
43
+ - test/fixtures/google_response_with_transfer_encoding
44
+ - test/fixtures/google_response_without_transfer_encoding
36
45
  - test/fixtures/test_example.txt
37
- - test/fixtures/test_request
46
+ - test/fixtures/test_txt_file
38
47
  - test/test_allow_net_connect.rb
39
48
  - test/test_fake_web.rb
40
49
  - test/test_fake_web_open_uri.rb
@@ -69,8 +78,11 @@ specification_version: 2
69
78
  summary: A tool for faking responses to HTTP requests
70
79
  test_files:
71
80
  - test/fixtures
81
+ - test/fixtures/google_response_from_curl
82
+ - test/fixtures/google_response_with_transfer_encoding
83
+ - test/fixtures/google_response_without_transfer_encoding
72
84
  - test/fixtures/test_example.txt
73
- - test/fixtures/test_request
85
+ - test/fixtures/test_txt_file
74
86
  - test/test_allow_net_connect.rb
75
87
  - test/test_fake_web.rb
76
88
  - test/test_fake_web_open_uri.rb
@@ -1,21 +0,0 @@
1
- HTTP/1.1 200 OK
2
- Cache-Control: private
3
- Content-Type: text/html
4
- Set-Cookie: PREF=ID=c1e3135f3180fabf:TM=1148188144:LM=1148188144:S=x9CJYC71XSKRA32Q; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
5
- Server: GWS/2.1
6
- Transfer-Encoding: chunked
7
- Date: Sun, 21 May 2006 05:09:04 GMT
8
-
9
- <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!--
10
- body,td,a,p,.h{font-family:arial,sans-serif;}
11
- .h{font-size: 20px;}
12
- .q{color:#0000cc;}
13
- -->
14
- </style>
15
- <script>
16
- <!--
17
- function sf(){document.f.q.focus();}
18
- // -->
19
- </script>
20
- </head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf() topmargin=3 marginheight=3><center><table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td align=right nowrap><font size=-1><a href="/url?sa=p&pref=ig&pval=2&q=http://www.google.com/ig%3Fhl%3Den">Personalized Home</a>&nbsp;|&nbsp;<a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></font></td></tr><tr height=4><td><img alt="" width=1 height=1></td></tr></table><img src="/intl/en/images/logo.gif" width=276 height=110 alt="Google"><br><br>
21
- <form action=/search name=f><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap><font size=-1><b>Web</b>&nbsp;&nbsp;&nbsp;&nbsp;<a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=2a class=q href="http://groups.google.com/grphp?hl=en&tab=wg&ie=UTF-8">Groups</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=4a class=q href="http://news.google.com/nwshp?hl=en&tab=wn&ie=UTF-8">News</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=5a class=q href="http://froogle.google.com/frghp?hl=en&tab=wf&ie=UTF-8">Froogle</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=7a class=q href="/maphp?hl=en&tab=wl&ie=UTF-8">Maps</a>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="/intl/en/options/" class=q>more&nbsp;&raquo;</a></b></font></td></tr></table><table cellspacing=0 cellpadding=0><tr><td width=25%>&nbsp;</td><td align=center><input type=hidden name=hl value=en><input type=hidden name=ie value="ISO-8859-1"><input maxlength=2048 size=55 name=q value="" title="Google Search"><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'm Feeling Lucky" name=btnI></td><td valign=top 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><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;2006 Google</font></p></center></body></html>