Sha256: 5f62ce070d98950ef8b3113becc5230edc91a9358f901f61b724633e8080f7f0

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

require 'logger'
require 'method_source'

def wait_for(timeout_milliseconds = 2000, &blk)
  timeout = timeout_milliseconds / 1000.0
  finish = Time.now + timeout
  result = nil

  while Time.now < finish && !(result = blk.call)
    sleep(0.001)
  end

  flunk("wait_for timed out:\n#{blk.source}") if !result
end

def test_config_for_backend(backend)
  config = {
    backend: backend,
    logger: Logger.new(IO::NULL),
  }

  case backend
  when :redis
    config[:url] = ENV['REDISURL']
  when :postgres
    config[:backend_options] = { host: ENV['PGHOST'], user: ENV['PGUSER'] || ENV['USER'], password: ENV['PGPASSWORD'], dbname: ENV['PGDATABASE'] || 'message_bus_test' }
  end
  config
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
message_bus-3.3.7 spec/helpers.rb