mongodoc 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.textile +42 -12
  2. data/Rakefile +4 -4
  3. data/TODO +26 -0
  4. data/VERSION +1 -1
  5. data/examples/simple_document.rb +1 -1
  6. data/examples/simple_object.rb +0 -2
  7. data/features/mongodb.yml +6 -5
  8. data/features/removing_documents.feature +68 -0
  9. data/features/step_definitions/collection_steps.rb +3 -3
  10. data/features/step_definitions/document_steps.rb +2 -2
  11. data/features/step_definitions/removing_documents_steps.rb +14 -0
  12. data/features/support/support.rb +2 -2
  13. data/lib/mongodoc.rb +4 -7
  14. data/lib/mongodoc/associations/collection_proxy.rb +103 -0
  15. data/lib/mongodoc/associations/document_proxy.rb +53 -0
  16. data/lib/mongodoc/associations/hash_proxy.rb +96 -0
  17. data/lib/mongodoc/associations/proxy_base.rb +51 -0
  18. data/lib/mongodoc/attributes.rb +49 -17
  19. data/lib/mongodoc/collection.rb +15 -5
  20. data/lib/mongodoc/connection.rb +83 -20
  21. data/lib/mongodoc/criteria.rb +9 -4
  22. data/lib/mongodoc/cursor.rb +9 -3
  23. data/lib/mongodoc/document.rb +37 -24
  24. data/lib/mongodoc/validations/macros.rb +11 -0
  25. data/lib/mongodoc/validations/validates_embedded.rb +13 -0
  26. data/mongodb.example.yml +13 -5
  27. data/mongodoc.gemspec +33 -23
  28. data/spec/associations/collection_proxy_spec.rb +200 -0
  29. data/spec/associations/document_proxy_spec.rb +42 -0
  30. data/spec/associations/hash_proxy_spec.rb +163 -0
  31. data/spec/attributes_spec.rb +113 -47
  32. data/spec/bson_spec.rb +24 -24
  33. data/spec/collection_spec.rb +67 -86
  34. data/spec/connection_spec.rb +98 -150
  35. data/spec/criteria_spec.rb +4 -3
  36. data/spec/cursor_spec.rb +33 -27
  37. data/spec/document_spec.rb +173 -156
  38. data/spec/embedded_save_spec.rb +8 -3
  39. data/spec/new_record_spec.rb +33 -121
  40. metadata +80 -39
  41. data/lib/mongodoc/parent_proxy.rb +0 -44
  42. data/lib/mongodoc/proxy.rb +0 -83
  43. data/spec/parent_proxy_spec.rb +0 -44
  44. data/spec/proxy_spec.rb +0 -80
@@ -1,179 +1,160 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "MongoDoc::Collection" do
4
- it ".mongo_collection creates a Mongo::Collection of the appropriate name" do
5
- name = 'collection_name'
6
- db = stub('db')
7
- db.should_receive(:collection).with(name)
8
- MongoDoc.should_receive(:database).and_return(db)
9
- MongoDoc::Collection.mongo_collection(name)
10
- end
11
4
 
12
- it ".new generates a Mongo::Collection by calling .mongo_collection" do
5
+ let(:mongo_collection) { stub('collection') }
6
+
7
+ it ".new delegates to .mongo_collection" do
13
8
  name = 'collection_name'
14
- MongoDoc::Collection.should_receive(:mongo_collection).with(name)
9
+ MongoDoc::Collection.should_receive(:mongo_collection).with(name).and_return(mongo_collection)
15
10
  MongoDoc::Collection.new(name)
16
11
  end
17
12
 
18
13
  context "with the underlying Mongo::Collection" do
19
- before do
20
- @mongo_collection = stub('collection')
21
- MongoDoc::Collection.stub(:mongo_collection).and_return(@mongo_collection)
22
- end
23
14
 
24
- it "#_collection is the underlying Mongo::Collection" do
25
- MongoDoc::Collection.new('collection_name')._collection.should == @mongo_collection
15
+ let(:collection) do
16
+ MongoDoc::Collection.stub(:mongo_collection).and_return(mongo_collection)
17
+ MongoDoc::Collection.new('collection_name')
26
18
  end
27
19
 
28
- %w([] clear count create_index db drop drop_index drop_indexes group hint index_information name options remove rename size).each do |delegated_method|
20
+ %w([] clear count create_index db distinct drop drop_index drop_indexes group hint index_information map_reduce mapreduce name options pk_factory remove rename size).each do |delegated_method|
29
21
  it "delegates #{delegated_method} to the Mongo::Collection" do
30
- @mongo_collection.should_receive(delegated_method)
31
- MongoDoc::Collection.new('collection_name').send(delegated_method)
22
+ mongo_collection.should_receive(delegated_method)
23
+ collection.send(delegated_method)
32
24
  end
33
25
  end
34
26
 
35
27
  context "#find" do
36
- before do
37
- @query = { 'sample' => 'data' }
38
- @options = {:limit => 1}
39
- @block = lambda {}
40
- @cursor = stub('cursor', :close => nil)
41
- @collection = MongoDoc::Collection.new('collection_name')
42
- @mongo_collection.stub(:find).and_return(@cursor)
43
- MongoDoc::Cursor.stub(:new).and_return(@cursor)
44
- end
28
+ let(:cursor) { MongoDoc::Cursor.new(collection, stub('cursor', :close => nil)) }
45
29
 
46
- it "delegates to the Mongo::Collection" do
47
- @mongo_collection.should_receive(:find).with(@query, @options, &@block).and_return(@cursor)
48
- @collection.find(@query, @options, &@block)
30
+ before do
31
+ collection.stub(:wrapped_cursor).and_return(cursor)
49
32
  end
50
33
 
51
34
  it "wraps the cursor" do
52
- MongoDoc::Cursor.should_receive(:new).with(@cursor).and_return(@cursor)
53
- @collection.find(@query, @options, &@block)
35
+ query = {'sample' => 'data'}
36
+ options = { :limit => 1}
37
+ collection.should_receive(:wrapped_cursor).with(query, options).and_return(cursor)
38
+ collection.find(query, options)
54
39
  end
55
40
 
56
41
  it "calls the block with a wrapped cursor" do
57
- @collection.find(@query, @options) {|cursor| @result = cursor}
58
- @result.should == @cursor
42
+ collection.find {|c| @result = c}
43
+ @result.should == cursor
59
44
  end
60
45
  end
61
46
 
62
47
  context "#find_one" do
48
+ let(:bson) { stub('bson') }
49
+
63
50
  before do
64
- @spec_or_object_id = { 'sample' => 'data' }
65
- @options = {:limit => 1}
66
- @collection = MongoDoc::Collection.new('collection_name')
67
- @bson = stub('bson')
68
- @mongo_collection.stub(:find_one).and_return(@bson)
51
+ mongo_collection.stub(:find_one).and_return(bson)
69
52
  end
70
53
 
71
54
  it "delegates to the Mongo::Collection" do
72
- @mongo_collection.should_receive(:find_one).with(@spec_or_object_id, @options)
73
- @collection.find_one(@spec_or_object_id, @options)
55
+ spec = { 'sample' => 'data' }
56
+ options = {:limit => 1}
57
+ mongo_collection.should_receive(:find_one).with(spec, options)
58
+ collection.find_one(spec, options)
74
59
  end
75
60
 
76
61
  it "converts the result back from bson" do
77
- MongoDoc::BSON.should_receive(:decode).with(@bson)
78
- @collection.find_one(@spec_or_object_id, @options)
62
+ MongoDoc::BSON.should_receive(:decode).with(bson)
63
+ collection.find_one({ 'sample' => 'data' })
79
64
  end
80
65
 
81
66
  it "returns the converted result" do
82
67
  obj = stub('obj')
83
68
  MongoDoc::BSON.stub(:decode).and_return(obj)
84
- @collection.find_one(@spec_or_object_id, @options).should == obj
69
+ collection.find_one({ 'sample' => 'data' }).should == obj
85
70
  end
86
71
 
87
72
  it "returns nil if the delegate returns nil" do
88
- @mongo_collection.stub(:find_one)
89
- @collection.find_one(@spec_or_object_id, @options).should be_nil
73
+ mongo_collection.stub(:find_one)
74
+ collection.find_one({ 'sample' => 'data' }).should be_nil
90
75
  end
91
76
  end
92
77
 
93
78
  context "#insert" do
94
- before do
95
- @doc = { 'sample' => 'data' }
96
- @options = {:safe => false}
97
- end
79
+ let(:doc) { {'sample' => 'data'} }
98
80
 
99
81
  it "delegates to the Mongo::Collection" do
100
- @mongo_collection.should_receive(:insert).with(@doc, @options)
101
- MongoDoc::Collection.new('collection_name').insert(@doc, @options)
82
+ options = {:safe => false}
83
+ mongo_collection.should_receive(:insert).with(doc, options)
84
+ collection.insert(doc, options)
102
85
  end
103
86
 
104
87
  it "converts the doc_or_docs to bson" do
105
- @doc.should_receive(:to_bson)
106
- @mongo_collection.stub(:insert)
107
- MongoDoc::Collection.new('collection_name').insert(@doc, @options)
88
+ doc.should_receive(:to_bson)
89
+ mongo_collection.stub(:insert)
90
+ collection.insert(doc, options)
108
91
  end
109
92
 
110
93
  it "returns the delegates result" do
111
94
  result = 'result'
112
- @mongo_collection.stub(:insert).and_return(result)
113
- MongoDoc::Collection.new('collection_name').insert(@doc, @options).should == result
95
+ mongo_collection.stub(:insert).and_return(result)
96
+ collection.insert(doc).should == result
114
97
  end
115
98
  end
116
99
 
117
100
  context "#save" do
118
- before do
119
- @doc = { 'sample' => 'data' }
120
- @options = {:safe => false}
121
- end
101
+ let(:doc) { {'sample' => 'data'} }
122
102
 
123
103
  it "delegates to the Mongo::Collection" do
124
- @mongo_collection.should_receive(:save).with(@doc, @options)
125
- MongoDoc::Collection.new('collection_name').save(@doc, @options)
104
+ options = {:safe => false}
105
+ mongo_collection.should_receive(:save).with(doc, options)
106
+ collection.save(doc, options)
126
107
  end
127
108
 
128
109
  it "converts the doc to bson" do
129
- @doc.should_receive(:to_bson)
130
- @mongo_collection.stub(:save)
131
- MongoDoc::Collection.new('collection_name').save(@doc, @options)
110
+ doc.should_receive(:to_bson)
111
+ mongo_collection.stub(:save)
112
+ collection.save(doc)
132
113
  end
133
114
 
134
115
  it "returns the delegates result" do
135
116
  result = 'result'
136
- @mongo_collection.stub(:save).and_return(result)
137
- MongoDoc::Collection.new('collection_name').save(@doc, @options).should == result
117
+ mongo_collection.stub(:save).and_return(result)
118
+ collection.save(doc).should == result
138
119
  end
139
120
  end
140
121
 
141
122
  context "#update" do
123
+ let(:spec) { {'sample' => 'old'} }
124
+
125
+ let(:doc) { {'sample' => 'data'} }
126
+
127
+ let(:options) { {:safe => false} }
128
+
142
129
  before do
143
- @spec = { 'sample' => 'old' }
144
- @doc = { 'sample' => 'data' }
145
- @options = {:safe => false}
146
- @database = stub('database', :command => nil)
147
- MongoDoc.stub(:database).and_return(@database)
130
+ collection.stub(:last_error).and_return('updatedExisting' => true)
131
+ mongo_collection.stub(:update)
148
132
  end
149
133
 
150
134
  it "delegates to the Mongo::Collection" do
151
- @mongo_collection.should_receive(:update).with(@spec, @doc, @options)
152
- MongoDoc::Collection.new('collection_name').update(@spec, @doc, @options)
135
+ mongo_collection.should_receive(:update).with(spec, doc, options)
136
+ collection.update(spec, doc, options)
153
137
  end
154
138
 
155
139
  it "converts the doc to bson" do
156
- @doc.should_receive(:to_bson)
157
- @mongo_collection.stub(:update)
158
- MongoDoc::Collection.new('collection_name').update(@spec, @doc, @options)
140
+ doc.should_receive(:to_bson)
141
+ collection.update(spec, doc, options)
159
142
  end
160
143
 
161
144
  it "gets the last error from the database" do
162
- @mongo_collection.stub(:update)
163
- @database.should_receive(:command).with({'getlasterror' => 1})
164
- MongoDoc::Collection.new('collection_name').update(@spec, @doc, @options)
145
+ collection.should_receive(:last_error)
146
+ collection.update(spec, doc, options)
165
147
  end
166
148
 
167
149
  it "returns the updateExisting value of get last error" do
168
150
  result = 'check'
169
- @mongo_collection.stub(:update)
170
- @database.stub(:command).and_return({'updatedExisting' => result})
171
- MongoDoc::Collection.new('collection_name').update(@spec, @doc, @options).should == result
151
+ collection.stub(:last_error).and_return({'updatedExisting' => result})
152
+ collection.update(spec, doc, options).should == result
172
153
  end
173
154
 
174
155
  it "returns false otherwise" do
175
- @mongo_collection.stub(:update)
176
- MongoDoc::Collection.new('collection_name').update(@spec, @doc, @options).should be_false
156
+ collection.stub(:last_error)
157
+ collection.update(spec, doc, options).should be_false
177
158
  end
178
159
  end
179
160
  end
@@ -1,199 +1,147 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "MongoDoc Connections" do
3
+ # Resets for testing
4
+ module MongoDoc
5
+ module Connection
6
+
7
+ def reset
8
+ @config_path = nil
9
+ @configuration = nil
10
+ @connection = nil
11
+ @database = nil
12
+ @host = nil
13
+ @name = nil
14
+ @options = nil
15
+ @port = nil
16
+ @strict = nil
17
+ end
4
18
 
5
- it "default the configuration location to './mongodb.yml'" do
6
- MongoDoc.config_path.should == './mongodb.yml'
7
19
  end
20
+ end
8
21
 
9
- describe ".connect" do
10
- before do
11
- MongoDoc.config_path = nil
12
- MongoDoc.connection = nil
13
- MongoDoc.config = nil
14
- @connection = stub('connection')
15
- end
22
+ describe "MongoDoc::Connection.Connections" do
16
23
 
17
- it "when called with no params just connects" do
18
- Mongo::Connection.should_receive(:new).and_return(@connection)
19
- MongoDoc.connect
20
- end
24
+ context "Non-rails environment" do
21
25
 
22
- it "sets the connection" do
23
- Mongo::Connection.stub(:new).and_return(@connection)
24
- MongoDoc.connect
25
- MongoDoc.connection.should == @connection
26
+ it "does not see Rails" do
27
+ Object.const_defined?('Rails').should be_false
26
28
  end
27
29
 
28
- it "raises NoConnectionError if the connection fails" do
29
- Mongo::Connection.stub(:new).and_return(nil)
30
- lambda { MongoDoc.connect }.should raise_error(MongoDoc::NoConnectionError)
30
+ it "default the configuration location to './mongodb.yml'" do
31
+ MongoDoc::Connection.config_path.should == './mongodb.yml'
31
32
  end
32
33
 
33
- context "mimics the Mongo::Connection API" do
34
- it "accepts the host param" do
35
- host = 'localhost'
36
- Mongo::Connection.should_receive(:new).with(host, nil, {}).and_return(@connection)
37
- MongoDoc.connect(host)
38
- end
34
+ context "without a configuration" do
35
+ let(:connection) { stub('connection') }
39
36
 
40
- it "accepts the port param" do
41
- host = 'localhost'
42
- port = 3000
43
- Mongo::Connection.should_receive(:new).with(host, 3000, {}).and_return(@connection)
44
- MongoDoc.connect(host, port)
37
+ before do
38
+ MongoDoc::Connection.reset
39
+ MongoDoc::Connection.stub(:connect).and_return(connection)
45
40
  end
46
41
 
47
- it "accepts an options hash" do
48
- opts = {:slave_ok => true}
49
- Mongo::Connection.should_receive(:new).with(nil, nil, opts).and_return(@connection)
50
- MongoDoc.connect(opts)
42
+ it "creates a default connection" do
43
+ MongoDoc::Connection.should_receive(:connect).and_return(connection)
44
+ MongoDoc::Connection.connection
51
45
  end
52
46
 
53
- it "accepts host, port, and options" do
54
- host = 'localhost'
55
- port = 3000
56
- opts = {:slave_ok => true}
57
- Mongo::Connection.should_receive(:new).with(host, 3000, opts).and_return(@connection)
58
- MongoDoc.connect(host, port, opts)
47
+ it "creates a default database with strict false" do
48
+ connection.should_receive(:db).with("mongodoc", :strict => false)
49
+ MongoDoc::Connection.database
59
50
  end
60
51
  end
52
+ end
61
53
 
62
- context "when there is a config file" do
63
- before do
64
- MongoDoc.config_path = './spec/mongodb.yml'
65
- config = YAML.load_file(MongoDoc.config_path)
66
- @host = config['host']
67
- @port = config['port']
68
- @db_options = config['options']
69
- end
70
-
71
- context "with a host config file" do
54
+ context "Rails environment" do
72
55
 
73
- it "and no params connects to the database with the values from the file" do
74
- Mongo::Connection.should_receive(:new).with(@host, @port, @db_options).and_return(@connection)
75
- MongoDoc.connect
76
- end
56
+ module FauxRails
57
+ extend self
77
58
 
78
- it "and params connects to the database with the params" do
79
- host = 'p_host'
80
- port = 890
81
- options = {:option => 'p_opt'}
82
- Mongo::Connection.should_receive(:new).with(host, port, options).and_return(@connection)
83
- MongoDoc.connect(host, port, options)
84
- end
59
+ def env
60
+ 'development'
85
61
  end
86
62
 
87
- context "with a host pairs config file" do
88
- before do
89
- MongoDoc.config_path = './spec/mongodb_pairs.yml'
90
- config = YAML.load_file(MongoDoc.config_path)
91
- @host_pairs = config['host_pairs']
92
- @port = config['port']
93
- @db_options = config['options']
94
- end
95
-
96
- it "connects to the database with the host pairs value from the file" do
97
- Mongo::Connection.should_receive(:new).with(@host_pairs, @port, @db_options).and_return(@connection)
98
- MongoDoc.connect
99
- end
63
+ def root
64
+ Pathname.new('rails_root')
100
65
  end
101
66
  end
102
- end
103
67
 
104
- describe ".connect_to_database" do
105
68
  before do
106
- MongoDoc.database = nil
107
- MongoDoc.connection = nil
108
- MongoDoc.config = nil
69
+ Object.const_set('Rails', FauxRails)
109
70
  end
110
71
 
111
- it "raises a no database error when the database connect failed" do
112
- connection = stub("connection", :db => nil)
113
- MongoDoc.stub(:connect).and_return(connection)
114
- lambda {MongoDoc.connect_to_database}.should raise_error(MongoDoc::NoDatabaseError)
72
+ after do
73
+ Object.send(:remove_const, 'Rails')
115
74
  end
116
75
 
117
- it "returns the database" do
118
- db = 'db'
119
- connection = stub("connection", :db => db)
120
- MongoDoc.stub(:connect).and_return(connection)
121
- MongoDoc.connect_to_database.should == db
76
+ it "sees Rails" do
77
+ Object.const_defined?('Rails').should be_true
122
78
  end
123
79
 
124
- context "when a connection exists" do
80
+ it "default the configuration location to Rails.root + '/config/mongodb.yml'" do
81
+ MongoDoc::Connection.config_path.should == FauxRails.root + 'config/mongodb.yml'
82
+ end
83
+
84
+ context "without a configuration" do
85
+ let(:connection) { stub('connection') }
86
+
125
87
  before do
126
- @db = 'db'
127
- @connection = stub("connection", :db => @db)
88
+ MongoDoc::Connection.reset
89
+ MongoDoc::Connection.stub(:connect).and_return(connection)
128
90
  end
129
91
 
130
- it "uses the exsiting connection if already connected" do
131
- MongoDoc.should_receive(:connection).and_return(@connection)
132
- MongoDoc.should_not_receive(:connect)
133
- MongoDoc.connect_to_database.should == @db
92
+ it "creates a default connection" do
93
+ MongoDoc::Connection.should_receive(:connect).and_return(connection)
94
+ MongoDoc::Connection.connection
134
95
  end
135
96
 
136
- it "connects if force connect is true" do
137
- MongoDoc.should_not_receive(:connection)
138
- MongoDoc.should_receive(:connect).and_return(@connection)
139
- MongoDoc.connect_to_database(nil, nil, nil, nil, true).should == @db
97
+ it "creates a default database with strict false" do
98
+ connection.should_receive(:db).with("rails_root_development", :strict => false)
99
+ MongoDoc::Connection.database
140
100
  end
141
101
  end
102
+ end
103
+
104
+ context ".verify_server_version" do
105
+ let(:connection) { stub('connection') }
106
+
107
+ it "raises when the server version is unsupported" do
108
+ connection.stub(:server_version).and_return(Mongo::ServerVersion.new('1.3.1'))
109
+ lambda { MongoDoc::Connection.send(:verify_server_version, connection) }.should raise_error(MongoDoc::UnsupportedServerVersionError)
110
+ end
142
111
 
143
- context "when there is no config file" do
144
- before do
145
- MongoDoc.config_path = nil
146
- @db = 'db'
147
- @name = 'name'
148
- @connection = stub('connection')
149
- end
112
+ it "returns when the server version is supported" do
113
+ connection.stub(:server_version).and_return(Mongo::ServerVersion.new('1.3.2'))
114
+ lambda { MongoDoc::Connection.send(:verify_server_version, connection) }.should_not raise_error(MongoDoc::UnsupportedServerVersionError)
115
+ end
116
+ end
150
117
 
151
- it "connects with defaults when not given parameters" do
152
- @connection.should_receive(:db).with(@name).and_return(@db)
153
- MongoDoc.should_receive(:connect).and_return(@connection)
154
- MongoDoc.connect_to_database(@name)
155
- end
118
+ describe ".connect" do
119
+ let(:connection) { stub('connection') }
156
120
 
157
- it "connects with the given parameters" do
158
- host = 'host'
159
- port = 123
160
- options = { :auto_reconnect => true }
161
- @connection.should_receive(:db).with(@name).and_return(@db)
162
- MongoDoc.should_receive(:connect).with(host, port, options).and_return(@connection)
163
- MongoDoc.connect_to_database(@name, host, port, options)
164
- end
121
+ before do
122
+ MongoDoc::Connection.stub(:verify_server_version)
165
123
  end
166
124
 
167
- context "when there is a config file" do
168
- before do
169
- @db = 'db'
170
- MongoDoc.config_path = './spec/mongodb.yml'
171
- config = YAML.load_file(MongoDoc.config_path)
172
- @database = config['name']
173
- @host = config['host']
174
- @port = config['port']
175
- @db_options = config['options']
176
- @connection = stub('connection')
177
- end
125
+ it "creates a Mongo::Connection" do
126
+ host = 'host'
127
+ port = 'port'
128
+ options = 'options'
129
+ MongoDoc::Connection.stub(:host).and_return(host)
130
+ MongoDoc::Connection.stub(:port).and_return(port)
131
+ MongoDoc::Connection.stub(:options).and_return(options)
132
+ Mongo::Connection.should_receive(:new).with(host, port, options).and_return(connection)
133
+ MongoDoc::Connection.send(:connect)
134
+ end
178
135
 
179
- context "with a host config file" do
180
-
181
- it "without a name uses configured name" do
182
- @connection.should_receive(:db).with(@database).and_return(@db)
183
- MongoDoc.stub(:connect).and_return(@connection)
184
- MongoDoc.connect_to_database
185
- end
186
-
187
- it "and params connects to the database with the params" do
188
- database = 'p_database'
189
- host = 'p_host'
190
- port = 890
191
- options = {:option => 'p_opt'}
192
- @connection.should_receive(:db).with(database).and_return(@db)
193
- MongoDoc.should_receive(:connect).with(host, port, options).and_return(@connection)
194
- MongoDoc.connect_to_database(database, host, port, options)
195
- end
196
- end
136
+ it "raises NoConnectionError if the connection fails" do
137
+ Mongo::Connection.stub(:new).and_return(nil)
138
+ lambda { MongoDoc::Connection.send(:connect) }.should raise_error(MongoDoc::NoConnectionError)
139
+ end
140
+
141
+ it "verifies the connection version" do
142
+ Mongo::Connection.stub(:new).and_return(connection)
143
+ MongoDoc::Connection.should_receive(:verify_server_version)
144
+ MongoDoc::Connection.send(:connect)
197
145
  end
198
146
  end
199
147
  end