1 require File.dirname(__FILE__) + '/helper'
3 class TestMetric < Test::Unit::TestCase
5 @metric = Metric.new(stub(:interval => 10), nil)
12 m = Metric.new(w, nil)
13 assert_equal w, m.watch
20 m = Metric.new(nil, d)
21 assert_equal d, m.destination
26 def test_condition_should_be_block_optional
27 @metric.condition(:fake_poll_condition)
28 assert_equal 1, @metric.conditions.size
31 def test_poll_condition_should_inherit_interval_from_watch_if_not_specified
32 @metric.condition(:fake_poll_condition)
33 assert_equal 10, @metric.conditions.first.interval
36 def test_poll_condition_should_abort_if_no_interval_and_no_watch_interval
37 metric = Metric.new(stub(:name => 'foo', :interval => nil), nil)
39 assert_raise AbortCalledError do
40 metric.condition(:fake_poll_condition)
44 def test_condition_should_allow_generation_of_subclasses_of_poll_or_event
45 metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
47 assert_nothing_raised do
48 metric.condition(:fake_poll_condition)
49 metric.condition(:fake_event_condition)
53 def test_condition_should_abort_if_not_subclass_of_poll_or_event
54 metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
56 assert_raise AbortCalledError do
57 metric.condition(:fake_condition) { |c| }