From a6dfeedb523ffc2b3d1fae5319b176b281c73084 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 21 Jan 2019 21:45:05 -0500 Subject: [PATCH] Reorder spec config methods --- spec/support/spec_config.rb | 79 +++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/spec/support/spec_config.rb b/spec/support/spec_config.rb index 1548e8c66a..dfb6da6136 100644 --- a/spec/support/spec_config.rb +++ b/spec/support/spec_config.rb @@ -34,6 +34,14 @@ def initialize end end + attr_reader :uri_options, :addresses, :connect_options + + # Environment + + def ci? + !!ENV['CI'] + end + def mri? !jruby? end @@ -46,12 +54,38 @@ def platform RUBY_PLATFORM end + # Test suite configuration + def client_debug? %w(1 true yes).include?((ENV['CLIENT_DEBUG'] || '').downcase) end - attr_reader :uri_options, :addresses, :connect_options + def drivers_tools? + !!ENV['DRIVERS_TOOLS'] + end + def active_support? + %w(1 true yes).include?(ENV['WITH_ACTIVE_SUPPORT']) + end + + # What compressor to use, if any. + def compressors + if ENV['COMPRESSORS'] + ENV['COMPRESSORS'].split(',') + else + nil + end + end + + def retry_writes? + %w(yes true on 1).include?((ENV['RETRY_WRITES'] || '').downcase) + end + + def ssl? + @ssl + end + + # Username, not user object def user @mongodb_uri && @mongodb_uri.credentials[:user] end @@ -68,6 +102,8 @@ def connect_replica_set? connect_options[:connect] == :replica_set end + # Derived data + # The write concern to use in the tests. def write_concern if connect_replica_set? @@ -81,14 +117,6 @@ def any_port addresses.first.split(':')[1] || '27017' end - def drivers_tools? - !!ENV['DRIVERS_TOOLS'] - end - - def ssl? - @ssl - end - def spec_root File.join(File.dirname(__FILE__), '..') end @@ -113,6 +141,13 @@ def client_key_pem end end + # The default test database for all specs. + def test_db + 'ruby-driver'.freeze + end + + # Option hashes + def ssl_options if ssl? { @@ -126,15 +161,6 @@ def ssl_options end end - # What compressor to use, if any. - def compressors - if ENV['COMPRESSORS'] - ENV['COMPRESSORS'].split(',') - else - nil - end - end - def compressor_options if compressors {compressors: compressors} @@ -143,10 +169,6 @@ def compressor_options end end - def retry_writes? - %w(yes true on 1).include?((ENV['RETRY_WRITES'] || '').downcase) - end - def retry_writes_options if retry_writes? {retry_writes: true} @@ -181,10 +203,7 @@ def test_options merge(ssl_options).merge(compressor_options).merge(retry_writes_options) end - # The default test database for all specs. - def test_db - 'ruby-driver'.freeze - end + # User objects # Gets the root system administrator user. def root_user @@ -226,12 +245,4 @@ def test_user ] ) end - - def ci? - !!ENV['CI'] - end - - def active_support? - %w(1 true yes).include?(ENV['WITH_ACTIVE_SUPPORT']) - end end