cotweet-fakeweb 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.autotest +5 -0
  2. data/.gitignore +7 -0
  3. data/CHANGELOG +215 -0
  4. data/LICENSE.txt +19 -0
  5. data/README.rdoc +189 -0
  6. data/Rakefile +67 -0
  7. data/fakeweb.gemspec +126 -0
  8. data/lib/fake_web.rb +215 -0
  9. data/lib/fake_web/ext/net_http.rb +72 -0
  10. data/lib/fake_web/registry.rb +127 -0
  11. data/lib/fake_web/responder.rb +122 -0
  12. data/lib/fake_web/response.rb +10 -0
  13. data/lib/fake_web/stub_socket.rb +15 -0
  14. data/lib/fake_web/utility.rb +90 -0
  15. data/lib/fakeweb.rb +2 -0
  16. data/test/fixtures/google_response_from_curl +12 -0
  17. data/test/fixtures/google_response_with_transfer_encoding +17 -0
  18. data/test/fixtures/google_response_without_transfer_encoding +11 -0
  19. data/test/fixtures/test_example.txt +1 -0
  20. data/test/fixtures/test_txt_file +3 -0
  21. data/test/test_allow_net_connect.rb +168 -0
  22. data/test/test_deprecations.rb +54 -0
  23. data/test/test_fake_authentication.rb +92 -0
  24. data/test/test_fake_web.rb +590 -0
  25. data/test/test_fake_web_open_uri.rb +58 -0
  26. data/test/test_helper.rb +90 -0
  27. data/test/test_last_request.rb +29 -0
  28. data/test/test_missing_open_uri.rb +25 -0
  29. data/test/test_missing_pathname.rb +37 -0
  30. data/test/test_other_net_http_libraries.rb +36 -0
  31. data/test/test_precedence.rb +79 -0
  32. data/test/test_query_string.rb +45 -0
  33. data/test/test_regexes.rb +157 -0
  34. data/test/test_response_headers.rb +79 -0
  35. data/test/test_trailing_slashes.rb +53 -0
  36. data/test/test_utility.rb +83 -0
  37. data/test/vendor/right_http_connection-1.2.4/History.txt +59 -0
  38. data/test/vendor/right_http_connection-1.2.4/Manifest.txt +7 -0
  39. data/test/vendor/right_http_connection-1.2.4/README.txt +54 -0
  40. data/test/vendor/right_http_connection-1.2.4/Rakefile +103 -0
  41. data/test/vendor/right_http_connection-1.2.4/lib/net_fix.rb +160 -0
  42. data/test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb +435 -0
  43. data/test/vendor/right_http_connection-1.2.4/setup.rb +1585 -0
  44. data/test/vendor/samuel-0.2.1/.document +5 -0
  45. data/test/vendor/samuel-0.2.1/.gitignore +5 -0
  46. data/test/vendor/samuel-0.2.1/LICENSE +20 -0
  47. data/test/vendor/samuel-0.2.1/README.rdoc +70 -0
  48. data/test/vendor/samuel-0.2.1/Rakefile +62 -0
  49. data/test/vendor/samuel-0.2.1/VERSION +1 -0
  50. data/test/vendor/samuel-0.2.1/lib/samuel.rb +52 -0
  51. data/test/vendor/samuel-0.2.1/lib/samuel/net_http.rb +10 -0
  52. data/test/vendor/samuel-0.2.1/lib/samuel/request.rb +96 -0
  53. data/test/vendor/samuel-0.2.1/samuel.gemspec +69 -0
  54. data/test/vendor/samuel-0.2.1/test/request_test.rb +193 -0
  55. data/test/vendor/samuel-0.2.1/test/samuel_test.rb +42 -0
  56. data/test/vendor/samuel-0.2.1/test/test_helper.rb +66 -0
  57. data/test/vendor/samuel-0.2.1/test/thread_test.rb +32 -0
  58. metadata +167 -0
data/.autotest ADDED
@@ -0,0 +1,5 @@
1
+ Autotest.add_hook :initialize do |autotest|
2
+ %w(.git vendor).each do |directory|
3
+ autotest.add_exception(directory)
4
+ end
5
+ end
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ /doc
2
+ /rdoc
3
+ /html
4
+ /coverage
5
+ /pkg
6
+ /.idea
7
+ *.rbc
data/CHANGELOG ADDED
@@ -0,0 +1,215 @@
1
+ fakeweb (1.3.0)
2
+
3
+ * improve response header registration so you can pass an array to set a header
4
+ more than once [Myron Marston]
5
+
6
+ * fix an exception when the response's :body option was set to nil [Chris Zingel]
7
+
8
+ * fix that stubbed requests weren't mutating the Net::HTTP request object to set
9
+ the body and content-length, like real requests do [Chris Kampmeier]
10
+
11
+ * add FakeWeb.last_request [Chris Kampmeier]
12
+
13
+ * assigning a String or Regexp to FakeWeb.allow_net_connect= sets a whitelist
14
+ for outbound requests [Dan Dofter, Tim Carey-Smith, Ben Woosley]
15
+
16
+
17
+ fakeweb (1.2.8)
18
+
19
+ * support Pathname objects where a filename is expected [Chris Kampmeier]
20
+
21
+ * fix compatibility with Ruby 1.9.2 [Chris Kampmeier]
22
+
23
+ * simplify storage of FakeWeb::VERSION [Josh Peek, Woody Peterson, Ben Woosley]
24
+
25
+
26
+ fakeweb (1.2.7)
27
+
28
+ * revert to sorting query params before matching requests against regexps,
29
+ instead of the 1.2.6 behavior that tried every possible order combination;
30
+ that was factorial-time, which made matching hang for requests with long query
31
+ strings [Jason Wadsworth, David Dollar, Blaine Cook]
32
+
33
+ * print a warning when FakeWeb is loaded before RightHttpConnection or after
34
+ Samuel, other libs that patch Net::HTTP [Chris Kampmeier, Ben Brinckerhoff]
35
+
36
+
37
+ fakeweb (1.2.6)
38
+
39
+ * fix that query params in a regex would have to be sorted for it to ever match
40
+ a request URI [Chris Kampmeier, Ben Hall]
41
+
42
+ * improve regex handling so registration with an explicit port (like
43
+ /example.com:80/) matches a request that uses an implied port
44
+ (like "http://example.com/") [Chris Kampmeier, Dan Dofter]
45
+
46
+ * refactor URI registry to reduce duplication; now about twice as fast at
47
+ handling requests [Chris Kampmeier]
48
+
49
+ * Add FakeWeb::VERSION so you can programmatically determine what version of
50
+ FakeWeb is loaded without using RubyGems [Chris Kampmeier, Chris Wanstrath]
51
+
52
+
53
+ fakeweb (1.2.5)
54
+
55
+ * fix handling of userinfo strings that contain percent-encoded unsafe
56
+ characters [Chris Kampmeier, Ken Mayer]
57
+
58
+ * fix that exact matches against strings/URIs with the :any method had a lower
59
+ precedence than regex matches using a real HTTP method (exact matches now
60
+ always take precedence) [Chris Kampmeier]
61
+
62
+ * change request handling to raise an exception when more than one registered
63
+ regex matches a request URI [Chris Kampmeier]
64
+
65
+
66
+ fakeweb (1.2.4)
67
+
68
+ * add experimental support for matching URIs via regular expressions
69
+ [Jacqui Maher, Tiago Albineli Motta, Peter Wagene]
70
+
71
+ * fix an exception when registering with the :response option and a string that
72
+ is the same as the name of a directory in the current path [Chris Kampmeier]
73
+
74
+ * DEPRECATION: Calling FakeWeb.register_uri with a :string or :file option is
75
+ now deprecated. Both options have been replaced with a unified :body option,
76
+ since they supply the response body (as opposed to :response, which supplies
77
+ the full response including headers) [Chris Kampmeier]
78
+
79
+ * add support for specifying HTTP headers as options to FakeWeb.register_uri
80
+ when using the :string or :file response types, since those methods only
81
+ specify a response body [David Michael, Chris Kampmeier]
82
+
83
+ * DEPRECATION: Calling FakeWeb.register_uri and FakeWeb.registered_uri? without
84
+ an HTTP method as the first argument is now deprecated. To match against any
85
+ HTTP method (the pre-1.2.0 behavior), use :any [Chris Kampmeier]
86
+
87
+
88
+ fakeweb (1.2.3)
89
+
90
+ * fix the #http_version of :file and :string responses, which was returning the
91
+ request URI instead of something sensible like "1.0" [Chris Kampmeier]
92
+
93
+ * add method aliases in the Net::HTTP patch to eliminate warnings when running
94
+ with -w [Joshua Clingenpeel]
95
+
96
+ * fix that removing the redefinition of OpenURI::HTTPError in 1.2.0 caused
97
+ :exception responses to raise when OpenURI isn't available [Chris Kampmeier]
98
+
99
+ * fix registering an :exception response with classes that require arguments for
100
+ instantiation, like Interrupt's subclasses [Chris Kampmeier]
101
+
102
+
103
+ fakeweb (1.2.2)
104
+
105
+ * fix that HTTP Digest and OAuth requests could raise URI::InvalidURIErrors
106
+ [Bill Kocik, Chris Kampmeier]
107
+
108
+
109
+ fakeweb (1.2.1)
110
+
111
+ * fix that query parameters are handled correctly when registering with a URI
112
+ object [Anselmo Alves, Chris Kampmeier]
113
+
114
+ * fix an exception when registering with the :response option and a string
115
+ containing "\0" [Jonathan Baudanza, Chris Kampmeier]
116
+
117
+ * fix that trailing slashes were considered significant for requests to the root
118
+ of a domain [Chris Kampmeier]
119
+
120
+ * add support for HTTP basic authentication via userinfo strings in URIs
121
+ [Michael Bleigh]
122
+
123
+
124
+ fakeweb (1.2.0)
125
+
126
+ * add lib/fakeweb.rb so you can require "fakeweb" as well [Chris Kampmeier]
127
+
128
+ * fix compatibility with Ruby 1.9.1 [Chris Kampmeier]
129
+
130
+ * fix that newlines in file-based responses could be doubled in the response
131
+ object's body [Mark Menard, Chris Kampmeier]
132
+
133
+ * fix unnecessary munging of the transfer-encoding header, which improves
134
+ compatibility with mechanize [Mark Menard]
135
+
136
+ * fix a test and the RCov dependency to be compatible with JRuby [Mark Menard]
137
+
138
+ * remove an unnecessary redefinition of OpenURI::HTTPError [Josh Nichols]
139
+
140
+ * rearrange implementation code into separate files, one per class [Josh Nichols]
141
+
142
+ * fix a bug where FakeWeb.response_for would raise if the request wasn't
143
+ registered [Chris Kampmeier]
144
+
145
+ * add HTTP method support, so FakeWeb takes both the URI and method into
146
+ account for registration, requests, and responses. Backwards-compatible with
147
+ the old method signatures, which didn't have a method param. [Chris Kampmeier]
148
+
149
+ * start work on Ruby 1.9 compatibility [Chris Kampmeier]
150
+
151
+ * add FakeWeb.allow_net_connect= to enable/disable the pass-through to
152
+ Net::HTTP for unregistered URIs [Mislav Marohnić, Chris Kampmeier]
153
+
154
+ * remove setup.rb, since most people use RubyGems [Mislav Marohnić]
155
+
156
+ * fix that 'http://example.com/?' (empty query) matches a registered
157
+ 'http://example.com/', and vice-versa [Mislav Marohnić]
158
+
159
+ * improve the test suite to not rely on an internet connection [Chris Kampmeier]
160
+
161
+ * use `rake test` instead of `rake tests` [Josh Nichols]
162
+
163
+ * fix an incompatibility with Ruby 1.8.6 p36 where you'd get "Errno::EINTR:
164
+ Interrupted system call" exceptions in Socket#sysread for any non-faked
165
+ request [Chris Kampmeier]
166
+
167
+ * response rotation: you can now optionally call FakeWeb.register_uri with an
168
+ array of options hashes; these are used, in order, to respond to
169
+ repeated requests (to repeat a response more than once before rotating, use
170
+ the :times option). Once you run out of responses, further requests always
171
+ receive the last response. [Michael Shapiro]
172
+
173
+ * add support for Net::HTTP's undocumented full-URI request style (fixes
174
+ URI::InvalidURIErrors that you might see in older libraries) [Chris Kampmeier]
175
+
176
+ * sort query params before storing internally, so that
177
+ http://example.com/?a=1&b=2 and http://example.com/?b=2&a=1 are considered the
178
+ same URL (although this is technically incorrect, it's much more
179
+ convenient--most web apps work that way, and Net::HTTP's use of a hash to pass
180
+ query params means that the order in which FakeWeb stores them can be
181
+ unpredictable) [Chris Kampmeier]
182
+
183
+ * add support for ports in URLs, so that http://example.com/ and
184
+ http://example.com:3000/ are not the same [Chris Kampmeier]
185
+
186
+ * fix for non-faked SSL requests failing with "Unable to create local socket"
187
+ [Chris Kampmeier]
188
+
189
+ * update Rakefile to fix warning about deprecated code [Chris Kampmeier]
190
+
191
+
192
+ fakeweb (1.1.2)
193
+
194
+ * add required dependencies to GemSpec to ensure that tests pass in firebrigade
195
+ (http://firebrigade.seattlerb.org/) [Blaine Cook]
196
+
197
+
198
+ fakeweb (1.1.1)
199
+
200
+ * fix for non-existence of :string method on File as presented by open-uri
201
+ [Blaine Cook]
202
+
203
+ * fix for curl example test - google redirects to ccTLDs for those outside US
204
+ [Blaine Cook]
205
+
206
+
207
+ fakeweb (1.1.0)
208
+
209
+ * update code to correspond to ruby 1.8.4 (breaks compatibility with ruby 1.8.2)
210
+ [Blaine Cook]
211
+
212
+
213
+ fakeweb (1.0.0)
214
+
215
+ * initial import [Blaine Cook]
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright 2006-2010 Blaine Cook, Chris Kampmeier, and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,189 @@
1
+ = FakeWeb
2
+
3
+ FakeWeb is a helper for faking web requests in Ruby. It works at a global
4
+ level, without modifying code or writing extensive stubs.
5
+
6
+
7
+ == Installation
8
+
9
+ gem install fakeweb
10
+
11
+ Note: the gem was previously available as +FakeWeb+ (capital letters), but now
12
+ all versions are simply registered as +fakeweb+. If you have any old +FakeWeb+
13
+ gems lying around, remove them: <tt>gem uninstall FakeWeb</tt>
14
+
15
+
16
+ == Help and discussion
17
+
18
+ RDocs for the current release are available at http://fakeweb.rubyforge.org.
19
+
20
+ There's a mailing list for questions and discussion at
21
+ http://groups.google.com/group/fakeweb-users.
22
+
23
+ The main source repository is http://github.com/chrisk/fakeweb.
24
+
25
+ == Examples
26
+
27
+ Start by requiring FakeWeb:
28
+
29
+ require 'fakeweb'
30
+
31
+ === Registering basic string responses
32
+
33
+ FakeWeb.register_uri(:get, "http://example.com/test1", :body => "Hello World!")
34
+
35
+ Net::HTTP.get(URI.parse("http://example.com/test1"))
36
+ => "Hello World!"
37
+
38
+ Net::HTTP.get(URI.parse("http://example.com/test2"))
39
+ => FakeWeb is bypassed and the response from a real request is returned
40
+
41
+ You can also call <tt>register_uri</tt> with a regular expression, to match
42
+ more than one URI.
43
+
44
+ FakeWeb.register_uri(:get, %r|http://example\.com/|, :body => "Hello World!")
45
+
46
+ Net::HTTP.get(URI.parse("http://example.com/test3"))
47
+ => "Hello World!"
48
+
49
+ === Replaying a recorded response
50
+
51
+ page = `curl -is http://www.google.com/`
52
+ FakeWeb.register_uri(:get, "http://www.google.com/", :response => page)
53
+
54
+ Net::HTTP.get(URI.parse("http://www.google.com/"))
55
+ # => Full response, including headers
56
+
57
+ === Adding a custom status to the response
58
+
59
+ FakeWeb.register_uri(:get, "http://example.com/", :body => "Nothing to be found 'round here",
60
+ :status => ["404", "Not Found"])
61
+
62
+ Net::HTTP.start("example.com") do |req|
63
+ response = req.get("/")
64
+ response.code # => "404"
65
+ response.message # => "Not Found"
66
+ response.body # => "Nothing to be found 'round here"
67
+ end
68
+
69
+ === Responding to any HTTP method
70
+
71
+ FakeWeb.register_uri(:any, "http://example.com", :body => "response for any HTTP method")
72
+
73
+ If you use the <tt>:any</tt> symbol, the URI you specify will be completely
74
+ stubbed out (regardless of the HTTP method of the request). This can be useful
75
+ for RPC-style services, where the HTTP method isn't significant. (Older
76
+ versions of FakeWeb always behaved like this, and didn't accept the first
77
+ +method+ argument above; this syntax is now deprecated.)
78
+
79
+ === Rotating responses
80
+
81
+ You can optionally call <tt>FakeWeb.register_uri</tt> with an array of options
82
+ hashes; these are used, in order, to respond to repeated requests. Once you run
83
+ out of responses, further requests always receive the last response. (You can
84
+ also send a response more than once before rotating, by specifying a
85
+ <tt>:times</tt> option for that response.)
86
+
87
+ FakeWeb.register_uri(:delete, "http://example.com/posts/1",
88
+ [{:body => "Post 1 deleted.", :status => ["200", "OK"]},
89
+ {:body => "Post not found", :status => ["404", "Not Found"]}])
90
+
91
+ Net::HTTP.start("example.com") do |req|
92
+ req.delete("/posts/1").body # => "Post 1 deleted"
93
+ req.delete("/posts/1").body # => "Post not found"
94
+ req.delete("/posts/1").body # => "Post not found"
95
+ end
96
+
97
+ === Using HTTP basic authentication
98
+
99
+ You can fake requests that use basic authentication by adding +userinfo+ strings
100
+ to your URIs:
101
+
102
+ FakeWeb.register_uri(:get, "http://example.com/secret", :body => "Unauthorized", :status => ["401", "Unauthorized"])
103
+ FakeWeb.register_uri(:get, "http://user:pass@example.com/secret", :body => "Authorized")
104
+
105
+ Net::HTTP.start("example.com") do |http|
106
+ req = Net::HTTP::Get.new("/secret")
107
+ http.request(req) # => "Unauthorized"
108
+ req.basic_auth("user", "pass")
109
+ http.request(req) # => "Authorized"
110
+ end
111
+
112
+ === Clearing registered URIs
113
+
114
+ The FakeWeb registry is a singleton that lasts for the duration of your program,
115
+ maintaining every fake response you register. If needed, you can clean out the
116
+ registry and remove all registered URIs:
117
+
118
+ FakeWeb.clean_registry
119
+
120
+ === Blocking all real requests
121
+
122
+ When you're using FakeWeb to replace _all_ of your requests, it's useful to
123
+ catch when requests are made for unregistered URIs (unlike the default
124
+ behavior, which is to pass those requests through to Net::HTTP as usual).
125
+
126
+ FakeWeb.allow_net_connect = false
127
+ Net::HTTP.get(URI.parse("http://example.com/"))
128
+ => raises FakeWeb::NetConnectNotAllowedError
129
+
130
+ FakeWeb.allow_net_connect = true
131
+ Net::HTTP.get(URI.parse("http://example.com/"))
132
+ => FakeWeb is bypassed and the response from a real request is returned
133
+
134
+ It's recommended that you set <tt>FakeWeb.allow_net_connect = false</tt> in the
135
+ setup for your tests.
136
+
137
+ ==== Allowing requests to a specific server
138
+
139
+ If you want to prevent your tests from hitting the internet while allowing
140
+ access to a specific server for integration testing, you can assign a URI or
141
+ +Regexp+ to be used as a whitelist for outbound requests:
142
+
143
+ FakeWeb.allow_net_connect = %r[^https?://localhost]
144
+ Net::HTTP.get(URI.parse("http://localhost/path")) # => allowed
145
+ Net::HTTP.get(URI.parse("http://example.com/")) # => raises FakeWeb::NetConnectNotAllowedError
146
+
147
+ === Specifying HTTP response headers
148
+
149
+ When you register a response using the <tt>:body</tt> option, you're only
150
+ setting the body of the response. If you want to add headers to these responses,
151
+ simply add the header as an option to +register_uri+:
152
+
153
+ FakeWeb.register_uri(:get, "http://example.com/hello.txt", :body => "Hello", :content_type => "text/plain")
154
+
155
+ This sets the "Content-Type" header in the response.
156
+
157
+ === Checking the last request
158
+
159
+ It's often useful to retrieve the last request made by your code, so you can
160
+ write tests for its content. FakeWeb keeps track of the last request, whether it
161
+ was stubbed or not:
162
+
163
+ Net::HTTP.get(URI.parse("http://example.com"))
164
+ FakeWeb.last_request # => Net::HTTP::Get request object
165
+
166
+ == More info
167
+
168
+ FakeWeb lets you decouple your test environment from live services without
169
+ modifying code or writing extensive stubs.
170
+
171
+ In addition to the conceptual advantage of having idempotent request
172
+ behaviour, FakeWeb makes tests run faster than if they were made to remote (or
173
+ even local) web servers. It also makes it possible to run tests without a
174
+ network connection or in situations where the server is behind a firewall or
175
+ has host-based access controls.
176
+
177
+ FakeWeb works with anything based on Net::HTTP--both higher-level wrappers,
178
+ like OpenURI, as well as a ton of libraries for popular web services.
179
+
180
+
181
+ == Known Issues
182
+
183
+ * Request bodies are ignored, including PUT and POST parameters. If you need
184
+ different responses for different request bodies, you need to request
185
+ different URLs, and register different responses for each. (Query strings are
186
+ fully supported, though.) We're currently considering how the API should
187
+ change to add support for request bodies in 1.3.0. Your input would be really
188
+ helpful: see http://groups.google.com/group/fakeweb-users/browse_thread/thread/44d190a6b12e4273
189
+ for a discussion of some different options. Thanks!
data/Rakefile ADDED
@@ -0,0 +1,67 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ version = '1.3.0'
5
+
6
+ begin
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = "fakeweb"
10
+ gem.rubyforge_project = "fakeweb"
11
+ gem.version = version
12
+ gem.summary = "A tool for faking responses to HTTP requests"
13
+ gem.description = "FakeWeb is a helper for faking web requests in Ruby. It works at a global level, without modifying code or writing extensive stubs."
14
+ gem.email = ["chris@kampers.net", "romeda@gmail.com"]
15
+ gem.authors = ["Chris Kampmeier", "Blaine Cook"]
16
+ gem.homepage = "http://github.com/chrisk/fakeweb"
17
+ gem.add_development_dependency "mocha", ">= 0.9.5"
18
+ end
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.test_files = FileList["test/**/*.rb"].exclude("test/test_helper.rb", "test/vendor")
27
+ test.libs << "test"
28
+ test.verbose = false
29
+ test.warning = true
30
+ end
31
+
32
+ task :default => [:check_dependencies, :test]
33
+
34
+
35
+ begin
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |t|
38
+ t.test_files = FileList["test/**/*.rb"].exclude("test/test_helper.rb", "test/vendor")
39
+ t.libs << "test"
40
+ t.rcov_opts << "--sort coverage"
41
+ t.rcov_opts << "--exclude gems"
42
+ t.warning = true
43
+ end
44
+ rescue LoadError
45
+ print "rcov support disabled "
46
+ if RUBY_PLATFORM =~ /java/
47
+ puts "(running under JRuby)"
48
+ else
49
+ puts "(install RCov to enable the `rcov` task)"
50
+ end
51
+ end
52
+
53
+
54
+ begin
55
+ require 'sdoc'
56
+ require 'rdoc/task'
57
+ Rake::RDocTask.new do |rdoc|
58
+ rdoc.main = "README.rdoc"
59
+ rdoc.rdoc_files.include("README.rdoc", "CHANGELOG", "LICENSE.txt", "lib/*.rb")
60
+ rdoc.title = "FakeWeb #{version} API Documentation"
61
+ rdoc.rdoc_dir = "doc"
62
+ rdoc.template = "direct"
63
+ rdoc.options << "--line-numbers" << "--show-hash" << "--charset=utf-8"
64
+ end
65
+ rescue LoadError
66
+ puts "SDoc (or a dependency) not available. Install it with: gem install sdoc"
67
+ end