test/dispatcher_test.rb in ardtweeno-0.3.1 vs test/dispatcher_test.rb in ardtweeno-0.4.0

- old
+ new

@@ -1,13 +1,12 @@ #################################################################################################### # @author David Kirwan https://github.com/davidkirwan/ardtweeno # @description Ardtweeno dispatcher test fixtures # -# @date 14-06-2013 +# @date 2013-06-14 #################################################################################################### -require 'rubygems' require 'test/unit' require 'rack/test' require 'ardtweeno' require 'logger' require 'json' @@ -17,13 +16,11 @@ class DispatcherTest < Test::Unit::TestCase include Rack::Test::Methods - attr_accessor :dispatch, :confdata - # Test suite fixtures def setup begin @@ -74,24 +71,24 @@ @nonode = {:notifyURL=>"http://192.168.1.2:5000/push/node1", :method=>"GET", :timeout=>60} - @nomethod = {:node=>"node1", + @nomethod = {:node=>"node2", :notifyURL=>"http://192.168.1.2:5000/push/node1", :timeout=>60} - @notimeout = {:node=>"node1", + @notimeout = {:node=>"node3", :notifyURL=>"http://192.168.1.2:5000/push/node1", :method=>"GET"} - @invalidtimeout = {:node=>"node1", + @invalidtimeout = {:node=>"node4", :notifyURL=>"http://192.168.1.2:5000/push/node1", :method=>"GET", :timeout=>-60} - @invalidmethod = {:node=>"node1", + @invalidmethod = {:node=>"node5", :notifyURL=>"http://192.168.1.2:5000/push/node1", :method=>"POSTSS", :timeout=>60} @@ -190,33 +187,39 @@ def test_add_watch assert_nothing_raised do @dispatch.addWatch(@validwatch) end + assert_equal({:watched=>true}, @dispatch.watched?({:node=>"node1"})) assert_raise Ardtweeno::AlreadyWatched do @dispatch.addWatch(@validwatch) end assert_raise Ardtweeno::InvalidWatch do @dispatch.addWatch(@nonode) end + assert_equal({:watched=>false}, @dispatch.watched?({})) assert_raise Ardtweeno::InvalidWatch do @dispatch.addWatch(@nomethod) end + assert_equal({:watched=>false}, @dispatch.watched?({:node=>"node2"})) assert_raise Ardtweeno::InvalidWatch do @dispatch.addWatch(@notimeout) end + assert_equal({:watched=>false}, @dispatch.watched?({:node=>"node3"})) assert_raise Ardtweeno::InvalidWatch do @dispatch.addWatch(@invalidtimeout) end + assert_equal({:watched=>false}, @dispatch.watched?({:node=>"node4"})) assert_raise Ardtweeno::InvalidWatch do @dispatch.addWatch(@invalidmethod) end + assert_equal({:watched=>false}, @dispatch.watched?({:node=>"node5"})) end # Test to ensure the Ardtweeno::Dispatcher#getPostsURI is working correctly \ No newline at end of file