Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 45 additions & 34 deletions spec/support/spec_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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?
Expand All @@ -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
Expand All @@ -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?
{
Expand All @@ -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}
Expand All @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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