-
Notifications
You must be signed in to change notification settings - Fork 19
/
meter_test.rb
32 lines (24 loc) · 869 Bytes
/
meter_test.rb
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
require 'test_helper'
class CountersWithRedis < IntegrationTest
def test_counters_can_act_like_gauges
50.times { instrument "event-counter", :counter => true }
meter = Harness::Meter.new 'event-counter'
assert_equal 50, meter.per_second.value
assert_equal 50, meter.per_minute.value
assert_equal 50, meter.per_hour.value
end
def tests_raises_an_error_when_no_such_counter
assert_raises Harness::NoCounter do
Harness::Meter.new 'unknown-counter'
end
end
def test_rates_return_gauges
50.times { instrument "event-counter", :counter => true }
meter = Harness::Meter.new 'event-counter'
gauge = meter.per_second
assert_kind_of Harness::Gauge, gauge
assert_equal "event-counter-per-second", gauge.id
assert_equal "event-counter per second", gauge.name
assert_kind_of Time, gauge.time
end
end