File: gauge_test.rb

package info (click to toggle)
ruby-metriks 0.9.9.8-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,877; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'test_helper'

require 'metriks/gauge'

class GaugeTest < Test::Unit::TestCase
  def test_gauge
    gauge = Metriks::Gauge.new

    3.times do |i|
      gauge.set(i + 1)
    end

    assert_equal 3, gauge.value

    gauge.set(1)

    assert_equal 1, gauge.value
  end

  def test_gauge_default
    gauge = Metriks::Gauge.new
    assert_equal nil, gauge.value
  end

  def test_gauge_callback_via_block
    gauge = Metriks::Gauge.new { 56 }

    assert_equal 56, gauge.value
  end

  def test_gauge_callback_via_callable_object
    callable = Class.new(Struct.new(:value)) {
      def call
        value
      end
    }

    gauge = Metriks::Gauge.new(callable.new(987))

    assert_equal 987, gauge.value

    gauge = Metriks::Gauge.new(proc { 123 })

    assert_equal 123, gauge.value
  end
end