Sha256: a0e99c10beeb503f2e14bf61cfee1fae456037c248ebae2f63f7de7273329049

Contents?: true

Size: 704 Bytes

Versions: 3

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'singleton'

class SpecConfig
  include Singleton

  def initialize
    if ENV['MONGODB_URI']
      @uri_str = ENV['MONGODB_URI']
      @uri = Mongo::URI.new(@uri_str)
    end
  end

  attr_reader :uri_str
  attr_reader :uri

  def addresses
    if @uri
      @uri.servers
    else
      ['127.0.0.1:27017']
    end
  end

  def mri?
    !jruby?
  end

  def jruby?
    RUBY_PLATFORM =~ /\bjava\b/
  end

  def platform
    RUBY_PLATFORM
  end

  def client_debug?
    %w(1 true yes).include?(ENV['CLIENT_DEBUG']&.downcase)
  end

  def app_tests?
    %w(1 true yes).include?(ENV['APP_TESTS']&.downcase)
  end

  def ci?
    !!ENV['CI']
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-7.2.1 spec/support/spec_config.rb
mongoid-7.2.0 spec/support/spec_config.rb
mongoid-7.2.0.rc1 spec/support/spec_config.rb