Sha256: 8c637b1170556d576c8c91b40e546f494d384bae813d2c86f9f8d6e1d64a6715

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

require 'test_helper'

class ClientTest < ChilloutTestCase

  def test_initialize_with_config
    config = Chillout::Config.new("xyz123")
    client = Chillout::Client.new(config)
    assert_equal config, client.config
  end

  def test_initialize_with_options_hash
    client = Chillout::Client.new("xyz123", :platform => 'rack')
    assert_equal "xyz123", client.config.api_key
    assert_equal "rack", client.config.platform
  end

  def test_initialize_with_block
    client = Chillout::Client.new("xyz") do |config|
      config.platform = "rack"
    end
    assert_equal "xyz", client.config.api_key
    assert_equal "rack", client.config.platform
  end

  def test_initialize_with_options_hash_and_block
    client = Chillout::Client.new("xyz", :platform => 'rack') do |config|
      config.port = 443
    end
    assert_equal "xyz", client.config.api_key
    assert_equal "rack", client.config.platform
    assert_equal 443, client.config.port
  end

  def test_initialize_with_unsupported_type_raises_an_error
    assert_raises(ArgumentError) do
      Chillout::Client.new(123)
    end
  end

  def test_enqueues_up_to_5K_metrics
    client = Chillout::Client.new("xyz")
    client.queue.expects(:size).returns(4999)
    client.queue.expects(:<<).returns(nil)
    client.enqueue(Object.new)
  end

  def test_does_not_enqueue_more_than_5K_metrics
    client = Chillout::Client.new("xyz")
    client.queue.expects(:size).returns(5000)
    client.queue.expects(:<<).never
    client.enqueue(Object.new)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chillout-0.8.9 test/client_test.rb
chillout-0.8.5.1 test/client_test.rb
chillout-0.8.8 test/client_test.rb
chillout-0.8.7 test/client_test.rb
chillout-0.8.6 test/client_test.rb
chillout-0.8.5 test/client_test.rb
chillout-0.8.4 test/client_test.rb
chillout-0.8.3 test/client_test.rb