Sha256: 1e4b47bf6548230326b4e64b0cec17ad83c9020b22f9c1eab52b55f3f6ed4415

Contents?: true

Size: 1.75 KB

Versions: 68

Compression:

Stored size: 1.75 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_abort 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_abort do
      metric.condition(:fake_condition) { |c| }
    end
  end
  
  def test_condition_should_abort_on_invalid_condition
    assert_abort do
      @metric.condition(:fake_poll_condition) { |c| c.stubs(:valid?).returns(false) }
    end
  end
  
  def test_condition_should_abort_on_no_such_condition
    assert_abort do
      @metric.condition(:invalid) { }
    end
  end
end

Version data entries

68 entries across 68 versions & 22 rubygems

Version Path
mojombo-god-0.7.11 test/test_metric.rb
mojombo-god-0.7.12 test/test_metric.rb
mojombo-god-0.7.13 test/test_metric.rb
mojombo-god-0.7.14 test/test_metric.rb
mojombo-god-0.7.15 test/test_metric.rb
mojombo-god-0.7.16 test/test_metric.rb
mojombo-god-0.7.20 test/test_metric.rb
mojombo-god-0.7.7 test/test_metric.rb
mojombo-god-0.7.9 test/test_metric.rb
obitum-god-0.7.14.1 test/test_metric.rb
obitum-god-0.7.14 test/test_metric.rb
pjhyett-god-0.7.12 test/test_metric.rb
relevance-god-0.7.12.1 test/test_metric.rb
relevance-god-0.7.12 test/test_metric.rb
saimonmoore-god-0.7.9 test/test_metric.rb
samhendley-god-0.7.13 test/test_metric.rb
strobemonkey-god-0.7.13 test/test_metric.rb
firenxis-god-0.11.0 test/test_metric.rb
god-0.11.0 test/test_metric.rb
god-0.10.1 test/test_metric.rb