Sha256: c7ae3b723eabbb4b8529a19132baa6382e121c9ed876425cf3c2a24bd07ea059

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require "helper"

class AdapterTest < ActiveSupport::TestCase
  test "wrap for statsd" do
    client_with_gauge_and_timing = Class.new do
      def increment(*args); end
      def gauge(*args); end
      def timing(*args); end
    end.new

    adapter = Nunes::Adapter.wrap(client_with_gauge_and_timing)
    assert_instance_of Nunes::Adapters::Default, adapter
  end

  test "wrap for instrumental" do
    client_with_gauge_but_not_timing = Class.new do
      def increment(*args); end
      def gauge(*args); end
    end.new

    adapter = Nunes::Adapter.wrap(client_with_gauge_but_not_timing)
    assert_instance_of Nunes::Adapters::TimingAliased, adapter
  end

  test "wrap for adapter" do
    memory = Nunes::Adapters::Memory.new
    adapter = Nunes::Adapter.wrap(memory)
    assert_equal memory, adapter
  end

  test "wrap with hash" do
    hash = {}
    adapter = Nunes::Adapter.wrap(hash)
    assert_instance_of Nunes::Adapters::Memory, adapter
  end

  test "wrap with nil" do
    assert_raises(ArgumentError) { Nunes::Adapter.wrap(nil) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nunes-0.1.0 test/adapter_test.rb