test_mongoid?

in elasticsearch-model/spec/spec_helper.rb [154:170]


def test_mongoid?
  $mongoid_available ||= begin
    require 'mongoid'
    if defined?(Mongo) 
      client = Mongo::Client.new(['localhost:27017'])
      Timeout.timeout(1) do
        client.database.command(ping: 1) && true
      end
    end and true
  rescue LoadError
    $stderr.puts("'mongoid' gem could not be loaded")
  rescue Timeout::Error, Mongo::Error => e
    client.close if client
    $stderr.puts("MongoDB not installed or running: #{e}")
  end
end