@@ -34,6 +34,14 @@ def initialize
3434 end
3535 end
3636
37+ attr_reader :uri_options , :addresses , :connect_options
38+
39+ # Environment
40+
41+ def ci?
42+ !!ENV [ 'CI' ]
43+ end
44+
3745 def mri?
3846 !jruby?
3947 end
@@ -46,12 +54,38 @@ def platform
4654 RUBY_PLATFORM
4755 end
4856
57+ # Test suite configuration
58+
4959 def client_debug?
5060 %w( 1 true yes ) . include? ( ( ENV [ 'CLIENT_DEBUG' ] || '' ) . downcase )
5161 end
5262
53- attr_reader :uri_options , :addresses , :connect_options
63+ def drivers_tools?
64+ !!ENV [ 'DRIVERS_TOOLS' ]
65+ end
5466
67+ def active_support?
68+ %w( 1 true yes ) . include? ( ENV [ 'WITH_ACTIVE_SUPPORT' ] )
69+ end
70+
71+ # What compressor to use, if any.
72+ def compressors
73+ if ENV [ 'COMPRESSORS' ]
74+ ENV [ 'COMPRESSORS' ] . split ( ',' )
75+ else
76+ nil
77+ end
78+ end
79+
80+ def retry_writes?
81+ %w( yes true on 1 ) . include? ( ( ENV [ 'RETRY_WRITES' ] || '' ) . downcase )
82+ end
83+
84+ def ssl?
85+ @ssl
86+ end
87+
88+ # Username, not user object
5589 def user
5690 @mongodb_uri && @mongodb_uri . credentials [ :user ]
5791 end
@@ -68,6 +102,8 @@ def connect_replica_set?
68102 connect_options [ :connect ] == :replica_set
69103 end
70104
105+ # Derived data
106+
71107 # The write concern to use in the tests.
72108 def write_concern
73109 if connect_replica_set?
@@ -81,14 +117,6 @@ def any_port
81117 addresses . first . split ( ':' ) [ 1 ] || '27017'
82118 end
83119
84- def drivers_tools?
85- !!ENV [ 'DRIVERS_TOOLS' ]
86- end
87-
88- def ssl?
89- @ssl
90- end
91-
92120 def spec_root
93121 File . join ( File . dirname ( __FILE__ ) , '..' )
94122 end
@@ -113,6 +141,13 @@ def client_key_pem
113141 end
114142 end
115143
144+ # The default test database for all specs.
145+ def test_db
146+ 'ruby-driver' . freeze
147+ end
148+
149+ # Option hashes
150+
116151 def ssl_options
117152 if ssl?
118153 {
@@ -126,15 +161,6 @@ def ssl_options
126161 end
127162 end
128163
129- # What compressor to use, if any.
130- def compressors
131- if ENV [ 'COMPRESSORS' ]
132- ENV [ 'COMPRESSORS' ] . split ( ',' )
133- else
134- nil
135- end
136- end
137-
138164 def compressor_options
139165 if compressors
140166 { compressors : compressors }
@@ -143,10 +169,6 @@ def compressor_options
143169 end
144170 end
145171
146- def retry_writes?
147- %w( yes true on 1 ) . include? ( ( ENV [ 'RETRY_WRITES' ] || '' ) . downcase )
148- end
149-
150172 def retry_writes_options
151173 if retry_writes?
152174 { retry_writes : true }
@@ -181,10 +203,7 @@ def test_options
181203 merge ( ssl_options ) . merge ( compressor_options ) . merge ( retry_writes_options )
182204 end
183205
184- # The default test database for all specs.
185- def test_db
186- 'ruby-driver' . freeze
187- end
206+ # User objects
188207
189208 # Gets the root system administrator user.
190209 def root_user
@@ -226,12 +245,4 @@ def test_user
226245 ]
227246 )
228247 end
229-
230- def ci?
231- !!ENV [ 'CI' ]
232- end
233-
234- def active_support?
235- %w( 1 true yes ) . include? ( ENV [ 'WITH_ACTIVE_SUPPORT' ] )
236- end
237248end
0 commit comments