Skip to content
Browse files

Merge pull request #48 from injekt/master

Fix warnings on 1.9
  • Loading branch information...
2 parents 93e9890 + c22263a commit 1016b7d66510470b373e82777aa95c3036127388 Lee Jarvis committed Jun 22, 2011
Showing with 39 additions and 39 deletions.
  1. +27 −27 lib/god/conditions/socket_responding.rb
  2. +1 −1 lib/god/event_handlers/dummy_handler.rb
  3. +11 −11 test/test_conditions_tries.rb
View
54 lib/god/conditions/socket_responding.rb
@@ -48,7 +48,7 @@ module Conditions
class SocketResponding < PollCondition
attr_accessor :family, :addr, :port, :path, :times
-
+
def initialize
super
# default to tcp on the localhost
@@ -57,9 +57,9 @@ def initialize
# Set these to nil/0 values
self.port = 0
self.path = nil
-
+
self.times = [1, 1]
- end
+ end
def prepare
if self.times.kind_of?(Integer)
@@ -100,32 +100,32 @@ def valid?
valid = false unless %w{tcp unix}.member?(self.family)
valid
end
-
+
def test
if self.family == 'tcp'
- begin
- s = TCPSocket.new(self.addr, self.port)
- rescue SystemCallError
- end
- status = s.nil?
- elsif self.family == 'unix'
- begin
- s = UNIXSocket.new(self.path)
- rescue SystemCallError
- end
- status = s.nil?
- else
- status = false
- end
- @timeline.push(status)
- history = "[" + @timeline.map {|s| s ? '*' : ''}.join(',') + "]"
- if @timeline.select { |x| x }.size >= self.times.first
- self.info = "socket out of bounds #{history}"
- return true
- else
- self.info = "socket within bounds #{history}"
- return false
- end
+ begin
+ s = TCPSocket.new(self.addr, self.port)
+ rescue SystemCallError
+ end
+ status = s.nil?
+ elsif self.family == 'unix'
+ begin
+ s = UNIXSocket.new(self.path)
+ rescue SystemCallError
+ end
+ status = s.nil?
+ else
+ status = false
+ end
+ @timeline.push(status)
+ history = "[" + @timeline.map {|t| t ? '*' : ''}.join(',') + "]"
+ if @timeline.select { |x| x }.size >= self.times.first
+ self.info = "socket out of bounds #{history}"
+ return true
+ else
+ self.info = "socket within bounds #{history}"
+ return false
+ end
end
end
end
View
2 lib/god/event_handlers/dummy_handler.rb
@@ -2,7 +2,7 @@ module God
class DummyHandler
EVENT_SYSTEM = "none"
- def self.register_process
+ def self.register_process(pid, events)
raise NotImplementedError
end
View
22 test/test_conditions_tries.rb
@@ -2,7 +2,7 @@
class TestConditionsTries < Test::Unit::TestCase
# valid?
-
+
def test_valid_should_return_false_if_times_not_set
c = Conditions::Tries.new
c.watch = stub(:name => 'foo')
@@ -17,23 +17,23 @@ def setup
@c.times = 3
@c.prepare
end
-
+
# prepare
-
+
def test_prepare_should_create_timeline
- assert 3, @c.instance_variable_get(:@timeline).instance_variable_get(:@max_size)
+ assert_equal 3, @c.instance_variable_get(:@timeline).instance_variable_get(:@max_size)
end
-
+
# test
-
+
def test_test_should_return_true_if_called_three_times_within_one_second
assert !@c.test
assert !@c.test
assert @c.test
end
-
+
# reset
-
+
def test_test_should_return_false_on_fourth_call_if_called_three_times_within_one_second
3.times { @c.test }
@c.reset
@@ -49,15 +49,15 @@ def setup
@c.within = 1.seconds
@c.prepare
end
-
+
# test
-
+
def test_test_should_return_true_if_called_three_times_within_one_second
assert !@c.test
assert !@c.test
assert @c.test
end
-
+
def test_test_should_return_false_if_called_three_times_within_two_seconds
assert !@c.test
assert !@c.test

0 comments on commit 1016b7d

Please sign in to comment.
Something went wrong with that request. Please try again.