mbleigh-fakeweb 1.1.3.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
- fakeweb (development)
1
+ fakeweb (1.2.0)
2
+
3
+ * add lib/fakeweb.rb so you can require "fakeweb" as well [Chris Kampmeier]
2
4
 
3
5
  * fix compatibility with Ruby 1.9.1 [Chris Kampmeier]
4
6
 
@@ -6,25 +6,22 @@ level, without modifying code or writing extensive stubs.
6
6
 
7
7
  == Installation
8
8
 
9
- This fork of Blaine Cook's original code has lots of fixes, stability
10
- improvements, and a few new features. It also has new support for Ruby 1.9.1
11
- and JRuby. To get it, install the latest gem directly from GitHub (currently
12
- 1.1.2.7):
9
+ The latest release of FakeWeb is once again available from your friendly
10
+ RubyForge mirror. Just install the gem:
13
11
 
14
- sudo gem install chrisk-fakeweb --source http://gems.github.com
12
+ sudo gem install fakeweb
15
13
 
14
+ Note: the gem was previously available as +FakeWeb+ (capital letters), but now
15
+ all versions are simply registered as +fakeweb+. If you have any old +FakeWeb+
16
+ gems lying around, remove them: <tt>sudo gem uninstall FakeWeb</tt>
16
17
 
17
- == Help and discussion
18
-
19
- There's a brand new mailing list at http://groups.google.com/group/fakeweb-users.
20
18
 
19
+ == Help and discussion
21
20
 
22
- == Development Notes
21
+ RDocs for the current release are available at http://fakeweb.rubyforge.org.
23
22
 
24
- We're currently considering how the API should change to add support for
25
- request bodies (see Known Issues below). Your input would be really helpful:
26
- see http://groups.google.com/group/fakeweb-users/browse_thread/thread/44d190a6b12e4273
27
- for a discussion of some different options. Thanks!
23
+ There's a mailing list for questions and discussion at
24
+ http://groups.google.com/group/fakeweb-users.
28
25
 
29
26
 
30
27
  == Examples
@@ -32,7 +29,7 @@ for a discussion of some different options. Thanks!
32
29
  Start by requiring FakeWeb:
33
30
 
34
31
  require 'rubygems'
35
- require 'fake_web'
32
+ require 'fakeweb'
36
33
 
37
34
  === Registering basic string responses
38
35
 
@@ -133,6 +130,7 @@ This is handy when you want to make sure your tests are self-contained, or you
133
130
  want to catch the scenario when a URI is changed in implementation code
134
131
  without a corresponding test change.
135
132
 
133
+
136
134
  == More info
137
135
 
138
136
  FakeWeb lets you decouple your test environment from live services without
@@ -152,8 +150,11 @@ like OpenURI, as well as a ton of libraries for popular web services.
152
150
 
153
151
  * Request bodies are ignored, including PUT and POST parameters. If you need
154
152
  different responses for different request bodies, you need to request
155
- different URLs, and register different responses for each. (Query strings
156
- are fully supported, though.)
153
+ different URLs, and register different responses for each. (Query strings are
154
+ fully supported, though.) We're currently considering how the API should
155
+ change to add support for request bodies in 1.3.0. Your input would be really
156
+ helpful: see http://groups.google.com/group/fakeweb-users/browse_thread/thread/44d190a6b12e4273
157
+ for a discussion of some different options. Thanks!
157
158
 
158
159
 
159
160
  == Copyright
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'rake/gempackagetask'
2
3
  require 'rake/testtask'
3
4
  require 'rake/rdoctask'
4
5
 
@@ -60,4 +61,10 @@ else
60
61
  t.rcov_opts << "--exclude gems"
61
62
  t.rcov_opts << "--no-validator-links"
62
63
  end
63
- end
64
+ end
65
+
66
+ spec = eval(File.read(File.join(File.dirname(__FILE__), "fakeweb.gemspec")))
67
+ Rake::GemPackageTask.new(spec) do |pkg|
68
+ pkg.need_tar_gz = true
69
+ pkg.need_zip = true
70
+ end
@@ -116,6 +116,29 @@ module FakeWeb
116
116
  Registry.instance.register_uri(method, uri, options)
117
117
  end
118
118
 
119
+ # call-seq:
120
+ # FakeWeb.unregister_uri(method, uri)
121
+ # FakeWeb.unregister_uri(uri)
122
+ #
123
+ # Unregister existing URIs with the given symbol `method` and `uri`.
124
+ # If you do not specify a `method` it will default to `:any` which
125
+ # will unregister any and all registered actions for the specified
126
+ # URI.
127
+ #
128
+ # Returns `true` if an existing URI is found, `false` if it wasn't
129
+ # registered to begin with.
130
+ #
131
+ def self.unregister_uri(*args)
132
+ method = :any
133
+ case args.length
134
+ when 2 then method, uri = *args
135
+ when 1 then uri = *args
136
+ else raise ArgumentError.new("wrong number of arguments (#{args.length} for method = :any, uri)")
137
+ end
138
+
139
+ Registry.instance.unregister_uri(method, uri)
140
+ end
141
+
119
142
  # call-seq:
120
143
  # FakeWeb.response_for(method, uri)
121
144
  # FakeWeb.response_for(uri)
@@ -150,4 +173,4 @@ module FakeWeb
150
173
  Registry.instance.registered_uri?(method, uri)
151
174
  end
152
175
 
153
- end
176
+ end
@@ -25,6 +25,12 @@ module FakeWeb
25
25
  uri_map[normalized_uri].has_key?(method) || uri_map[normalized_uri].has_key?(:any)
26
26
  end
27
27
 
28
+ def unregister_uri(method, uri)
29
+ normalized_uri = normalize_uri(uri)
30
+ return !!uri_map.delete(normalized_uri) if method == :any
31
+ !!uri_map[normalized_uri].delete(method)
32
+ end
33
+
28
34
  def registered_uri(method, uri)
29
35
  uri = normalize_uri(uri)
30
36
  registered = registered_uri?(method, uri)
@@ -75,4 +81,4 @@ module FakeWeb
75
81
  end
76
82
 
77
83
  end
78
- end
84
+ end
@@ -0,0 +1,2 @@
1
+ # So you can require "fakeweb" instead of "fake_web"
2
+ require "fake_web"
@@ -105,6 +105,41 @@ class TestFakeWeb < Test::Unit::TestCase
105
105
  assert !FakeWeb.registered_uri?("http://example.com/users")
106
106
  end
107
107
 
108
+ def test_unregister_uri_for_get_method_only
109
+ FakeWeb.register_uri(:get, 'http://example.com/users', :string => 'User list')
110
+ assert FakeWeb.registered_uri?(:get, "http://example.com/users")
111
+ assert FakeWeb.unregister_uri(:get, 'http://example.com/users')
112
+ assert !FakeWeb.registered_uri?(:get, "http://example.com/users")
113
+ end
114
+
115
+ def test_unregister_uri_for_any_method_explicitly
116
+ FakeWeb.register_uri(:get, 'http://example.com/users', :string => 'User list')
117
+ FakeWeb.register_uri(:post, 'http://example.com/users', :string => 'Create Users')
118
+ assert FakeWeb.unregister_uri(:any, 'http://example.com/users')
119
+ assert !FakeWeb.registered_uri?(:get, 'http://example.com/users')
120
+ assert !FakeWeb.registered_uri?(:post, 'http://example.com/users')
121
+ end
122
+
123
+ def test_unregister_uri_without_method_specified
124
+ FakeWeb.register_uri(:get, 'http://example.com/users', :string => 'User list')
125
+ FakeWeb.register_uri(:post, 'http://example.com/users', :string => 'Create Users')
126
+ assert FakeWeb.unregister_uri('http://example.com/users')
127
+ assert !FakeWeb.registered_uri?(:get, 'http://example.com/users')
128
+ assert !FakeWeb.registered_uri?(:post, 'http://example.com/users')
129
+ end
130
+
131
+ def test_unregister_uri_on_unregistered_uri
132
+ assert !FakeWeb.unregister_uri('http://example.com/unregistered')
133
+ end
134
+
135
+ def test_unregister_uri_leaves_other_uris_alone
136
+ FakeWeb.register_uri(:get, 'http://example.com/users', :string => 'User list')
137
+ FakeWeb.register_uri(:post, 'http://example.com/other', :string => 'Create Users')
138
+ assert FakeWeb.unregister_uri('http://example.com/users')
139
+ assert !FakeWeb.registered_uri?(:get, 'http://example.com/users')
140
+ assert FakeWeb.registered_uri?(:post, 'http://example.com/other')
141
+ end
142
+
108
143
  def test_response_for_with_registered_uri
109
144
  FakeWeb.register_uri('http://mock/test_example.txt', :file => File.dirname(__FILE__) + '/fixtures/test_example.txt')
110
145
  assert_equal 'test example content', FakeWeb.response_for('http://mock/test_example.txt').body
@@ -482,4 +517,8 @@ class TestFakeWeb < Test::Unit::TestCase
482
517
  end
483
518
  assert response.body.split(/\n/).size == 3, "response has #{response.body.split(/\n/).size} lines should have 3"
484
519
  end
520
+
521
+ def test_requiring_fakeweb_instead_of_fake_web
522
+ require "fakeweb"
523
+ end
485
524
  end
metadata CHANGED
@@ -1,20 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbleigh-fakeweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3.9
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blaine Cook
8
+ - Chris Kampmeier
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-02-19 00:00:00 -08:00
13
+ date: 2009-03-07 00:00:00 -08:00
13
14
  default_executable:
14
- dependencies: []
15
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mocha
18
+ type: :development
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.9.5
25
+ version:
16
26
  description:
17
- email:
27
+ email: chris@kampers.net
18
28
  executables: []
19
29
 
20
30
  extensions: []
@@ -35,8 +45,9 @@ files:
35
45
  - lib/fake_web/ext/net_http.rb
36
46
  - lib/fake_web/registry.rb
37
47
  - lib/fake_web/responder.rb
38
- - lib/fake_web/stub_socket.rb
39
48
  - lib/fake_web/response.rb
49
+ - lib/fake_web/stub_socket.rb
50
+ - lib/fakeweb.rb
40
51
  - test
41
52
  - test/fixtures
42
53
  - test/fixtures/google_response_from_curl
@@ -49,12 +60,19 @@ files:
49
60
  - test/test_fake_web_open_uri.rb
50
61
  - test/test_helper.rb
51
62
  - test/test_query_string.rb
63
+ - test/test_fake_authentication.rb
52
64
  has_rdoc: true
53
65
  homepage: http://github.com/chrisk/fakeweb
54
66
  post_install_message:
55
67
  rdoc_options:
56
68
  - --main
57
69
  - README.rdoc
70
+ - --title
71
+ - FakeWeb API Documentation
72
+ - --charset
73
+ - utf-8
74
+ - --line-numbers
75
+ - --inline-source
58
76
  require_paths:
59
77
  - lib
60
78
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -71,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
89
  version:
72
90
  requirements: []
73
91
 
74
- rubyforge_project:
92
+ rubyforge_project: fakeweb
75
93
  rubygems_version: 1.2.0
76
94
  signing_key:
77
95
  specification_version: 2