Sha256: b0d71be31b7dc2b7d102a4a55b0b7eb1da69b46d244da36289706c62a66cc432

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestMetric < Test::Unit::TestCase
  def setup
    @metric = Metric.new(stub(:interval => 10), nil)
  end
  
  # watch
  
  def test_watch
    w = stub()
    m = Metric.new(w, nil)
    assert_equal w, m.watch
  end
  
  # destination
  
  def test_destination
    d = stub()
    m = Metric.new(nil, d)
    assert_equal d, m.destination
  end
  
  # condition
  
  def test_condition_should_be_block_optional
    @metric.condition(:fake_poll_condition)
    assert_equal 1, @metric.conditions.size
  end
  
  def test_poll_condition_should_inherit_interval_from_watch_if_not_specified
    @metric.condition(:fake_poll_condition)
    assert_equal 10, @metric.conditions.first.interval
  end
  
  def test_poll_condition_should_abort_if_no_interval_and_no_watch_interval
    metric = Metric.new(stub(:name => 'foo', :interval => nil), nil)
    
    assert_raise AbortCalledError do
      metric.condition(:fake_poll_condition)
    end
  end
  
  def test_condition_should_allow_generation_of_subclasses_of_poll_or_event
    metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
    
    assert_nothing_raised do
      metric.condition(:fake_poll_condition)
      metric.condition(:fake_event_condition)
    end
  end
  
  def test_condition_should_abort_if_not_subclass_of_poll_or_event
    metric = Metric.new(stub(:name => 'foo', :interval => 10), nil)
    
    assert_raise AbortCalledError do
      metric.condition(:fake_condition) { |c| }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
god-0.2.0 test/test_metric.rb