implemented cli control
[god.git] / test / test_meddle.rb
blobbea63d74b185c69b715bd0fb6212598d6ab834b7
1 require File.dirname(__FILE__) + '/helper'
3 class TestMeddle < Test::Unit::TestCase
4   def setup
5     Server.stubs(:new).returns(true)
6     @meddle = Meddle.new
7   end
8   
9   def test_should_initialize_watches_to_empty_array
10     assert_equal Hash.new, @meddle.watches
11   end
12   
13   def test_watches_should_get_stored
14     watch = nil
15     @meddle.watch { |w| watch = w }
16     
17     assert_equal 1, @meddle.watches.size
18     assert_equal watch, @meddle.watches.values.first
19   end
21   def test_should_kick_off_a_server_instance
22     Server.expects(:new).returns(true)
23     Meddle.new
24   end
26   def test_should_take_an_options_hash
27     Server.expects(:new)
28     Meddle.new(:port => 5555)
29   end
30   
31   def test_should_allow_multiple_watches
32     @meddle.watch { |w| w.name = 'foo' }
33     
34     assert_nothing_raised do
35       @meddle.watch { |w| w.name = 'bar' }
36     end
37   end
38   
39   def test_should_disallow_duplicate_watch_names
40     @meddle.watch { |w| w.name = 'foo' }
41     
42     assert_raise AbortCalledError do
43       @meddle.watch { |w| w.name = 'foo' }
44     end
45   end
46 end