Sha256: 547366cc08d323b77f5ca7bea149e7f85c70b1e78e236fc0ca695cc5953c0d92

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module TestClient
  def test_client
    if defined? $test_client and $test_client.ping
      return $test_client
    end

    candidate_client = Riak::Client.new test_client_configuration

    live = candidate_client.ping

    return $test_client = candidate_client if live
  end

  def test_client_configuration
    TestClient.test_client_configuration
  end

  def self.test_client_configuration
    if defined? $test_client_configuration
      return $test_client_configuration
    end

    config_path = File.expand_path '../test_client.yml', __FILE__
    config = YAML.load_file(config_path).symbolize_keys

    if config[:nodes]
      new_nodes = config[:nodes].map(&:symbolize_keys)
      config[:nodes] = new_nodes
    end

    $test_client_configuration = config
  end

  def random_bucket(name = 'test_client')
    bucket_name = [name, Time.now.to_i, random_key].join('-')
    test_client.bucket bucket_name
  end

  def random_key
    rand(36**10).to_s(36)
  end
end

RSpec.configure do |config|
  config.include TestClient, test_client: true
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
riak-client-2.4.0 spec/support/test_client.rb
riak-client-2.4.0.pre1 spec/support/test_client.rb
riak-client-2.3.2 spec/support/test_client.rb
riak-client-2.3.1 spec/support/test_client.rb
riak-client-2.3.0 spec/support/test_client.rb
riak-client-2.2.2 spec/support/test_client.rb
riak-client-2.2.1 spec/support/test_client.rb
riak-client-noenc-1.0.0 spec/support/test_client.rb
riak-client-2.2.0 spec/support/test_client.rb