1 require File.dirname(__FILE__) + '/helper'
3 class TestMeddle < Test::Unit::TestCase
5 Server.stubs(:new).returns(true)
10 def test_should_initialize_watches_to_empty_array
11 assert_equal Hash.new, @meddle.watches
14 def test_watches_should_get_stored
16 @meddle.watch { |w| watch = w }
18 assert_equal 1, @meddle.watches.size
19 assert_equal watch, @meddle.watches.values.first
21 assert_equal 0, @meddle.groups.size
24 def test_watches_should_register_processes
25 assert_nil God.registry['foo']
26 @meddle.watch { |w| w.name = 'foo' }
27 assert_kind_of God::Process, God.registry['foo']
30 def test_watches_should_get_stored_by_group
36 assert_equal({'test' => ['foo']}, @meddle.groups)
39 def test_multiple_watches_should_get_stored_by_group
50 assert_equal({'test' => ['foo', 'bar']}, @meddle.groups)
53 def test_should_kick_off_a_server_instance
54 Server.expects(:new).returns(true)
58 def test_should_take_an_options_hash
60 Meddle.new(:port => 5555)
63 def test_should_allow_multiple_watches
64 @meddle.watch { |w| w.name = 'foo' }
66 assert_nothing_raised do
67 @meddle.watch { |w| w.name = 'bar' }
71 def test_should_disallow_duplicate_watch_names
72 @meddle.watch { |w| w.name = 'foo' }
74 assert_raise AbortCalledError do
75 @meddle.watch { |w| w.name = 'foo' }