mattetti-couchrest 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/LICENSE +176 -0
  2. data/README.md +93 -0
  3. data/Rakefile +66 -0
  4. data/THANKS.md +18 -0
  5. data/examples/model/example.rb +144 -0
  6. data/examples/word_count/markov +38 -0
  7. data/examples/word_count/views/books/chunked-map.js +3 -0
  8. data/examples/word_count/views/books/united-map.js +1 -0
  9. data/examples/word_count/views/markov/chain-map.js +6 -0
  10. data/examples/word_count/views/markov/chain-reduce.js +7 -0
  11. data/examples/word_count/views/word_count/count-map.js +6 -0
  12. data/examples/word_count/views/word_count/count-reduce.js +3 -0
  13. data/examples/word_count/word_count.rb +46 -0
  14. data/examples/word_count/word_count_query.rb +40 -0
  15. data/examples/word_count/word_count_views.rb +26 -0
  16. data/lib/couchrest/commands/generate.rb +71 -0
  17. data/lib/couchrest/commands/push.rb +103 -0
  18. data/lib/couchrest/core/database.rb +313 -0
  19. data/lib/couchrest/core/design.rb +89 -0
  20. data/lib/couchrest/core/document.rb +96 -0
  21. data/lib/couchrest/core/response.rb +16 -0
  22. data/lib/couchrest/core/server.rb +88 -0
  23. data/lib/couchrest/core/view.rb +4 -0
  24. data/lib/couchrest/helper/pager.rb +103 -0
  25. data/lib/couchrest/helper/streamer.rb +44 -0
  26. data/lib/couchrest/mixins/attachments.rb +31 -0
  27. data/lib/couchrest/mixins/callbacks.rb +442 -0
  28. data/lib/couchrest/mixins/design_doc.rb +63 -0
  29. data/lib/couchrest/mixins/document_queries.rb +48 -0
  30. data/lib/couchrest/mixins/extended_attachments.rb +68 -0
  31. data/lib/couchrest/mixins/extended_document_mixins.rb +6 -0
  32. data/lib/couchrest/mixins/properties.rb +125 -0
  33. data/lib/couchrest/mixins/validation.rb +234 -0
  34. data/lib/couchrest/mixins/views.rb +169 -0
  35. data/lib/couchrest/mixins.rb +4 -0
  36. data/lib/couchrest/monkeypatches.rb +113 -0
  37. data/lib/couchrest/more/casted_model.rb +28 -0
  38. data/lib/couchrest/more/extended_document.rb +217 -0
  39. data/lib/couchrest/more/property.rb +40 -0
  40. data/lib/couchrest/support/blank.rb +42 -0
  41. data/lib/couchrest/support/class.rb +175 -0
  42. data/lib/couchrest/validation/auto_validate.rb +163 -0
  43. data/lib/couchrest/validation/contextual_validators.rb +78 -0
  44. data/lib/couchrest/validation/validation_errors.rb +118 -0
  45. data/lib/couchrest/validation/validators/absent_field_validator.rb +74 -0
  46. data/lib/couchrest/validation/validators/confirmation_validator.rb +99 -0
  47. data/lib/couchrest/validation/validators/format_validator.rb +117 -0
  48. data/lib/couchrest/validation/validators/formats/email.rb +66 -0
  49. data/lib/couchrest/validation/validators/formats/url.rb +43 -0
  50. data/lib/couchrest/validation/validators/generic_validator.rb +120 -0
  51. data/lib/couchrest/validation/validators/length_validator.rb +134 -0
  52. data/lib/couchrest/validation/validators/method_validator.rb +89 -0
  53. data/lib/couchrest/validation/validators/numeric_validator.rb +104 -0
  54. data/lib/couchrest/validation/validators/required_field_validator.rb +109 -0
  55. data/lib/couchrest.rb +189 -0
  56. data/spec/couchrest/core/couchrest_spec.rb +201 -0
  57. data/spec/couchrest/core/database_spec.rb +745 -0
  58. data/spec/couchrest/core/design_spec.rb +131 -0
  59. data/spec/couchrest/core/document_spec.rb +311 -0
  60. data/spec/couchrest/core/server_spec.rb +35 -0
  61. data/spec/couchrest/helpers/pager_spec.rb +122 -0
  62. data/spec/couchrest/helpers/streamer_spec.rb +23 -0
  63. data/spec/couchrest/more/casted_extended_doc_spec.rb +40 -0
  64. data/spec/couchrest/more/casted_model_spec.rb +97 -0
  65. data/spec/couchrest/more/extended_doc_attachment_spec.rb +129 -0
  66. data/spec/couchrest/more/extended_doc_spec.rb +509 -0
  67. data/spec/couchrest/more/extended_doc_view_spec.rb +207 -0
  68. data/spec/couchrest/more/property_spec.rb +129 -0
  69. data/spec/fixtures/attachments/README +3 -0
  70. data/spec/fixtures/attachments/couchdb.png +0 -0
  71. data/spec/fixtures/attachments/test.html +11 -0
  72. data/spec/fixtures/more/article.rb +34 -0
  73. data/spec/fixtures/more/card.rb +20 -0
  74. data/spec/fixtures/more/course.rb +14 -0
  75. data/spec/fixtures/more/event.rb +6 -0
  76. data/spec/fixtures/more/invoice.rb +17 -0
  77. data/spec/fixtures/more/person.rb +8 -0
  78. data/spec/fixtures/more/question.rb +6 -0
  79. data/spec/fixtures/more/service.rb +12 -0
  80. data/spec/fixtures/views/lib.js +3 -0
  81. data/spec/fixtures/views/test_view/lib.js +3 -0
  82. data/spec/fixtures/views/test_view/only-map.js +4 -0
  83. data/spec/fixtures/views/test_view/test-map.js +3 -0
  84. data/spec/fixtures/views/test_view/test-reduce.js +3 -0
  85. data/spec/spec.opts +6 -0
  86. data/spec/spec_helper.rb +26 -0
  87. data/utils/remap.rb +27 -0
  88. data/utils/subset.rb +30 -0
  89. metadata +217 -0
@@ -0,0 +1,109 @@
1
+ # Extracted from dm-validations 0.9.10
2
+ #
3
+ # Copyright (c) 2007 Guy van den Berg
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ module CouchRest
25
+ module Validation
26
+
27
+ ##
28
+ #
29
+ # @author Guy van den Berg
30
+ # @since 0.9
31
+ class RequiredFieldValidator < GenericValidator
32
+
33
+ def initialize(field_name, options={})
34
+ super
35
+ @field_name, @options = field_name, options
36
+ end
37
+
38
+ def call(target)
39
+ value = target.validation_property_value(field_name)
40
+ property = target.validation_property(field_name)
41
+ return true if present?(value, property)
42
+
43
+ error_message = @options[:message] || default_error(property)
44
+ add_error(target, error_message, field_name)
45
+
46
+ false
47
+ end
48
+
49
+ protected
50
+
51
+ # Boolean property types are considered present if non-nil.
52
+ # Other property types are considered present if non-blank.
53
+ # Non-properties are considered present if non-blank.
54
+ def present?(value, property)
55
+ boolean_type?(property) ? !value.nil? : !value.blank?
56
+ end
57
+
58
+ def default_error(property)
59
+ actual = boolean_type?(property) ? :nil : :blank
60
+ ValidationErrors.default_error_message(actual, field_name)
61
+ end
62
+
63
+ # Is +property+ a boolean property?
64
+ #
65
+ # Returns true for Boolean, ParanoidBoolean, TrueClass, etc. properties.
66
+ # Returns false for other property types.
67
+ # Returns false for non-properties.
68
+ def boolean_type?(property)
69
+ property ? property.type == TrueClass : false
70
+ end
71
+
72
+ end # class RequiredFieldValidator
73
+
74
+ module ValidatesPresent
75
+
76
+ ##
77
+ # Validates that the specified attribute is present.
78
+ #
79
+ # For most property types "being present" is the same as being "not
80
+ # blank" as determined by the attribute's #blank? method. However, in
81
+ # the case of Boolean, "being present" means not nil; i.e. true or
82
+ # false.
83
+ #
84
+ # @note
85
+ # dm-core's support lib adds the blank? method to many classes,
86
+ # @see lib/dm-core/support/blank.rb (dm-core) for more information.
87
+ #
88
+ # @example [Usage]
89
+ #
90
+ # class Page
91
+ #
92
+ # property :required_attribute, String
93
+ # property :another_required, String
94
+ # property :yet_again, String
95
+ #
96
+ # validates_present :required_attribute
97
+ # validates_present :another_required, :yet_again
98
+ #
99
+ # # a call to valid? will return false unless
100
+ # # all three attributes are !blank?
101
+ # end
102
+ def validates_present(*fields)
103
+ opts = opts_from_validator_args(fields)
104
+ add_validator_to_context(opts, fields, CouchRest::Validation::RequiredFieldValidator)
105
+ end
106
+
107
+ end # module ValidatesPresent
108
+ end # module Validation
109
+ end # module CouchRest
data/lib/couchrest.rb ADDED
@@ -0,0 +1,189 @@
1
+ # Copyright 2008 J. Chris Anderson
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "rubygems"
16
+ gem 'json'
17
+ require 'json'
18
+ gem 'rest-client'
19
+ require 'rest_client'
20
+
21
+ $:.unshift File.dirname(__FILE__) unless
22
+ $:.include?(File.dirname(__FILE__)) ||
23
+ $:.include?(File.expand_path(File.dirname(__FILE__)))
24
+
25
+ $COUCHREST_DEBUG ||= false
26
+
27
+ require 'couchrest/monkeypatches'
28
+
29
+ # = CouchDB, close to the metal
30
+ module CouchRest
31
+ VERSION = '0.2' unless self.const_defined?("VERSION")
32
+
33
+ autoload :Server, 'couchrest/core/server'
34
+ autoload :Database, 'couchrest/core/database'
35
+ autoload :Response, 'couchrest/core/response'
36
+ autoload :Document, 'couchrest/core/document'
37
+ autoload :Design, 'couchrest/core/design'
38
+ autoload :View, 'couchrest/core/view'
39
+ autoload :Model, 'couchrest/core/model'
40
+ autoload :Pager, 'couchrest/helper/pager'
41
+ autoload :FileManager, 'couchrest/helper/file_manager'
42
+ autoload :Streamer, 'couchrest/helper/streamer'
43
+
44
+ autoload :ExtendedDocument, 'couchrest/more/extended_document'
45
+ autoload :CastedModel, 'couchrest/more/casted_model'
46
+
47
+ require File.join(File.dirname(__FILE__), 'couchrest', 'mixins')
48
+
49
+ # The CouchRest module methods handle the basic JSON serialization
50
+ # and deserialization, as well as query parameters. The module also includes
51
+ # some helpers for tasks like instantiating a new Database or Server instance.
52
+ class << self
53
+
54
+ # extracted from Extlib
55
+ #
56
+ # Constantize tries to find a declared constant with the name specified
57
+ # in the string. It raises a NameError when the name is not in CamelCase
58
+ # or is not initialized.
59
+ #
60
+ # @example
61
+ # "Module".constantize #=> Module
62
+ # "Class".constantize #=> Class
63
+ def constantize(camel_cased_word)
64
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
65
+ raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
66
+ end
67
+
68
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
69
+ end
70
+
71
+ # todo, make this parse the url and instantiate a Server or Database instance
72
+ # depending on the specificity.
73
+ def new(*opts)
74
+ Server.new(*opts)
75
+ end
76
+
77
+ def parse url
78
+ case url
79
+ when /^http:\/\/(.*)\/(.*)\/(.*)/
80
+ host = $1
81
+ db = $2
82
+ docid = $3
83
+ when /^http:\/\/(.*)\/(.*)/
84
+ host = $1
85
+ db = $2
86
+ when /^http:\/\/(.*)/
87
+ host = $1
88
+ when /(.*)\/(.*)\/(.*)/
89
+ host = $1
90
+ db = $2
91
+ docid = $3
92
+ when /(.*)\/(.*)/
93
+ host = $1
94
+ db = $2
95
+ else
96
+ db = url
97
+ end
98
+
99
+ db = nil if db && db.empty?
100
+
101
+ {
102
+ :host => host || "127.0.0.1:5984",
103
+ :database => db,
104
+ :doc => docid
105
+ }
106
+ end
107
+
108
+ # set proxy for RestClient to use
109
+ def proxy url
110
+ RestClient.proxy = url
111
+ end
112
+
113
+ # ensure that a database exists
114
+ # creates it if it isn't already there
115
+ # returns it after it's been created
116
+ def database! url
117
+ parsed = parse url
118
+ cr = CouchRest.new(parsed[:host])
119
+ cr.database!(parsed[:database])
120
+ end
121
+
122
+ def database url
123
+ parsed = parse url
124
+ cr = CouchRest.new(parsed[:host])
125
+ cr.database(parsed[:database])
126
+ end
127
+
128
+ def put(uri, doc = nil)
129
+ payload = doc.to_json if doc
130
+ begin
131
+ JSON.parse(RestClient.put(uri, payload))
132
+ rescue Exception => e
133
+ if $COUCHREST_DEBUG == true
134
+ raise "Error while sending a PUT request #{uri}\npayload: #{payload.inspect}\n#{e}"
135
+ else
136
+ raise e
137
+ end
138
+ end
139
+ end
140
+
141
+ def get(uri)
142
+ begin
143
+ JSON.parse(RestClient.get(uri), :max_nesting => false)
144
+ rescue => e
145
+ if $COUCHREST_DEBUG == true
146
+ raise "Error while sending a GET request #{uri}\n: #{e}"
147
+ else
148
+ raise e
149
+ end
150
+ end
151
+ end
152
+
153
+ def post uri, doc = nil
154
+ payload = doc.to_json if doc
155
+ begin
156
+ JSON.parse(RestClient.post(uri, payload))
157
+ rescue Exception => e
158
+ if $COUCHREST_DEBUG == true
159
+ raise "Error while sending a POST request #{uri}\npayload: #{payload.inspect}\n#{e}"
160
+ else
161
+ raise e
162
+ end
163
+ end
164
+ end
165
+
166
+ def delete uri
167
+ JSON.parse(RestClient.delete(uri))
168
+ end
169
+
170
+ def copy uri, destination
171
+ JSON.parse(RestClient.copy(uri, {'Destination' => destination}))
172
+ end
173
+
174
+ def move uri, destination
175
+ JSON.parse(RestClient.move(uri, {'Destination' => destination}))
176
+ end
177
+
178
+ def paramify_url url, params = {}
179
+ if params && !params.empty?
180
+ query = params.collect do |k,v|
181
+ v = v.to_json if %w{key startkey endkey}.include?(k.to_s)
182
+ "#{k}=#{CGI.escape(v.to_s)}"
183
+ end.join("&")
184
+ url = "#{url}?#{query}"
185
+ end
186
+ url
187
+ end
188
+ end # class << self
189
+ end
@@ -0,0 +1,201 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe CouchRest do
4
+
5
+ before(:each) do
6
+ @cr = CouchRest.new(COUCHHOST)
7
+ begin
8
+ @db = @cr.database(TESTDB)
9
+ @db.delete! rescue nil
10
+ end
11
+ end
12
+
13
+ after(:each) do
14
+ begin
15
+ @db.delete! rescue nil
16
+ end
17
+ end
18
+
19
+ describe "getting info" do
20
+ it "should list databases" do
21
+ @cr.databases.should be_an_instance_of(Array)
22
+ end
23
+ it "should get info" do
24
+ @cr.info["couchdb"].should == "Welcome"
25
+ @cr.info.class.should == Hash
26
+ end
27
+ end
28
+
29
+ it "should restart" do
30
+ @cr.restart!
31
+ end
32
+
33
+ it "should provide one-time access to uuids" do
34
+ @cr.next_uuid.should_not be_nil
35
+ end
36
+
37
+ describe "initializing a database" do
38
+ it "should return a db" do
39
+ db = @cr.database(TESTDB)
40
+ db.should be_an_instance_of(CouchRest::Database)
41
+ db.host.should == @cr.uri
42
+ end
43
+ end
44
+
45
+ describe "parsing urls" do
46
+ it "should parse just a dbname" do
47
+ db = CouchRest.parse "my-db"
48
+ db[:database].should == "my-db"
49
+ db[:host].should == "127.0.0.1:5984"
50
+ end
51
+ it "should parse a host and db" do
52
+ db = CouchRest.parse "127.0.0.1/my-db"
53
+ db[:database].should == "my-db"
54
+ db[:host].should == "127.0.0.1"
55
+ end
56
+ it "should parse a host and db with http" do
57
+ db = CouchRest.parse "http://127.0.0.1/my-db"
58
+ db[:database].should == "my-db"
59
+ db[:host].should == "127.0.0.1"
60
+ end
61
+ it "should parse a host with a port and db" do
62
+ db = CouchRest.parse "127.0.0.1:5555/my-db"
63
+ db[:database].should == "my-db"
64
+ db[:host].should == "127.0.0.1:5555"
65
+ end
66
+ it "should parse a host with a port and db with http" do
67
+ db = CouchRest.parse "http://127.0.0.1:5555/my-db"
68
+ db[:database].should == "my-db"
69
+ db[:host].should == "127.0.0.1:5555"
70
+ end
71
+ it "should parse just a host" do
72
+ db = CouchRest.parse "http://127.0.0.1:5555/"
73
+ db[:database].should be_nil
74
+ db[:host].should == "127.0.0.1:5555"
75
+ end
76
+ it "should parse just a host no slash" do
77
+ db = CouchRest.parse "http://127.0.0.1:5555"
78
+ db[:host].should == "127.0.0.1:5555"
79
+ db[:database].should be_nil
80
+ end
81
+ it "should get docid" do
82
+ db = CouchRest.parse "127.0.0.1:5555/my-db/my-doc"
83
+ db[:database].should == "my-db"
84
+ db[:host].should == "127.0.0.1:5555"
85
+ db[:doc].should == "my-doc"
86
+ end
87
+ it "should get docid with http" do
88
+ db = CouchRest.parse "http://127.0.0.1:5555/my-db/my-doc"
89
+ db[:database].should == "my-db"
90
+ db[:host].should == "127.0.0.1:5555"
91
+ db[:doc].should == "my-doc"
92
+ end
93
+
94
+ it "should parse a host and db" do
95
+ db = CouchRest.parse "127.0.0.1/my-db"
96
+ db[:database].should == "my-db"
97
+ db[:host].should == "127.0.0.1"
98
+ end
99
+ it "should parse a host and db with http" do
100
+ db = CouchRest.parse "http://127.0.0.1/my-db"
101
+ db[:database].should == "my-db"
102
+ db[:host].should == "127.0.0.1"
103
+ end
104
+ it "should parse a host with a port and db" do
105
+ db = CouchRest.parse "127.0.0.1:5555/my-db"
106
+ db[:database].should == "my-db"
107
+ db[:host].should == "127.0.0.1:5555"
108
+ end
109
+ it "should parse a host with a port and db with http" do
110
+ db = CouchRest.parse "http://127.0.0.1:5555/my-db"
111
+ db[:database].should == "my-db"
112
+ db[:host].should == "127.0.0.1:5555"
113
+ end
114
+ it "should parse just a host" do
115
+ db = CouchRest.parse "http://127.0.0.1:5555/"
116
+ db[:database].should be_nil
117
+ db[:host].should == "127.0.0.1:5555"
118
+ end
119
+ it "should parse just a host no slash" do
120
+ db = CouchRest.parse "http://127.0.0.1:5555"
121
+ db[:host].should == "127.0.0.1:5555"
122
+ db[:database].should be_nil
123
+ end
124
+ it "should get docid" do
125
+ db = CouchRest.parse "127.0.0.1:5555/my-db/my-doc"
126
+ db[:database].should == "my-db"
127
+ db[:host].should == "127.0.0.1:5555"
128
+ db[:doc].should == "my-doc"
129
+ end
130
+ it "should get docid with http" do
131
+ db = CouchRest.parse "http://127.0.0.1:5555/my-db/my-doc"
132
+ db[:database].should == "my-db"
133
+ db[:host].should == "127.0.0.1:5555"
134
+ db[:doc].should == "my-doc"
135
+ end
136
+ end
137
+
138
+ describe "easy initializing a database adapter" do
139
+ it "should be possible without an explicit CouchRest instantiation" do
140
+ db = CouchRest.database "http://127.0.0.1:5984/couchrest-test"
141
+ db.should be_an_instance_of(CouchRest::Database)
142
+ db.host.should == "127.0.0.1:5984"
143
+ end
144
+ # TODO add https support (need test environment...)
145
+ # it "should work with https" # do
146
+ # db = CouchRest.database "https://127.0.0.1:5984/couchrest-test"
147
+ # db.host.should == "https://127.0.0.1:5984"
148
+ # end
149
+ it "should not create the database automatically" do
150
+ db = CouchRest.database "http://127.0.0.1:5984/couchrest-test"
151
+ lambda{db.info}.should raise_error(RestClient::ResourceNotFound)
152
+ end
153
+ end
154
+
155
+ describe "ensuring the db exists" do
156
+ it "should be super easy" do
157
+ db = CouchRest.database! "http://127.0.0.1:5984/couchrest-test-2"
158
+ db.name.should == 'couchrest-test-2'
159
+ db.info["db_name"].should == 'couchrest-test-2'
160
+ end
161
+ end
162
+
163
+ describe "successfully creating a database" do
164
+ it "should start without a database" do
165
+ @cr.databases.should_not include(TESTDB)
166
+ end
167
+ it "should return the created database" do
168
+ db = @cr.create_db(TESTDB)
169
+ db.should be_an_instance_of(CouchRest::Database)
170
+ end
171
+ it "should create the database" do
172
+ db = @cr.create_db(TESTDB)
173
+ @cr.databases.should include(TESTDB)
174
+ end
175
+ end
176
+
177
+ describe "failing to create a database because the name is taken" do
178
+ before(:each) do
179
+ db = @cr.create_db(TESTDB)
180
+ end
181
+ it "should start with the test database" do
182
+ @cr.databases.should include(TESTDB)
183
+ end
184
+ it "should PUT the database and raise an error" do
185
+ lambda{
186
+ @cr.create_db(TESTDB)
187
+ }.should raise_error(RestClient::Request::RequestFailed)
188
+ end
189
+ end
190
+
191
+ describe "using a proxy for RestClient connections" do
192
+ it "should set proxy url for RestClient" do
193
+ CouchRest.proxy 'http://localhost:8888/'
194
+ proxy_uri = URI.parse(RestClient.proxy)
195
+ proxy_uri.host.should eql( 'localhost' )
196
+ proxy_uri.port.should eql( 8888 )
197
+ CouchRest.proxy nil
198
+ end
199
+ end
200
+
201
+ end