test/test_growl_udp.rb in ruby-growl-4.0 vs test/test_growl_udp.rb in ruby-growl-4.1

- old
+ new

@@ -1,9 +1,9 @@ require 'minitest/autorun' require 'ruby-growl' -class TestGrowlUDP < MiniTest::Unit::TestCase +class TestGrowlUDP < Minitest::Test def setup @growl = Growl::UDP.new "localhost", "ruby-growl test", ["ruby-growl Test Notification"] end @@ -198,9 +198,38 @@ packet = @growl.notification_packet "Command-Line Growl Notification", "", "hi", 0, true assert_equal expected, util_hexes(packet) + end + + def test_socket + @udp = Growl::UDP.allocate + + socket = @udp.socket "localhost" + + refute socket.getsockopt(:SOL_SOCKET, :SO_BROADCAST).bool + end + + def test_socket_broadcast + @udp = Growl::UDP.allocate + + socket = @udp.socket "255.255.255.255" + + assert socket.getsockopt(:SOL_SOCKET, :SO_BROADCAST).bool + end + + def test_socket_subnet_broadcast + skip "Socket.getifaddrs not supported" unless + Socket.respond_to? :getifaddrs + + ifaddr = Socket.getifaddrs.find { |ifaddr| ifaddr.broadaddr } + + @udp = Growl::UDP.allocate + + socket = @udp.socket ifaddr.broadaddr.ip_address + + assert socket.getsockopt(:SOL_SOCKET, :SO_BROADCAST).bool end def util_hexes string if string.respond_to? :ord then string.scan(/./).map { |c| "%02x" % c.ord }