diff --git a/lib/semian/circuit_breaker.rb b/lib/semian/circuit_breaker.rb index 480734456..995f11a82 100644 --- a/lib/semian/circuit_breaker.rb +++ b/lib/semian/circuit_breaker.rb @@ -3,7 +3,7 @@ class CircuitBreaker #:nodoc: extend Forwardable def initialize(name, exceptions:, success_threshold:, error_threshold:, error_timeout:, permissions:, implementation:) - @name = name.to_s + @name = name.to_sym @success_count_threshold = success_threshold @error_count_threshold = error_threshold @error_timeout = error_timeout diff --git a/lib/semian/simple_integer.rb b/lib/semian/simple_integer.rb index 44d17a259..aff732204 100644 --- a/lib/semian/simple_integer.rb +++ b/lib/semian/simple_integer.rb @@ -4,7 +4,7 @@ class Integer #:nodoc: attr_accessor :value def initialize - @value = 0 + reset end def increment(val = 1) diff --git a/lib/semian/simple_sliding_window.rb b/lib/semian/simple_sliding_window.rb index 0da819706..cfdcb74f9 100644 --- a/lib/semian/simple_sliding_window.rb +++ b/lib/semian/simple_sliding_window.rb @@ -24,9 +24,9 @@ def resize_to(size) self end - def push(time_ms) + def push(value) @window.shift while @window.size >= @max_size - @window << time_ms + @window << value self end diff --git a/test/simple_integer_test.rb b/test/simple_integer_test.rb index a571ede33..195051d9f 100644 --- a/test/simple_integer_test.rb +++ b/test/simple_integer_test.rb @@ -5,7 +5,6 @@ class TestSimpleInteger < MiniTest::Unit::TestCase def setup @integer = CLASS.new - @integer.value = 0 end def teardown @@ -14,7 +13,6 @@ def teardown module IntegerTestCases def test_access_value - @integer.value = 0 assert_equal(0, @integer.value) @integer.value = 99 assert_equal(99, @integer.value) @@ -28,7 +26,6 @@ def test_access_value end def test_increment - @integer.value = 0 @integer.increment(4) assert_equal(4, @integer.value) @integer.increment @@ -36,6 +33,16 @@ def test_increment @integer.increment(-2) assert_equal(3, @integer.value) end + + def test_reset_on_init + assert_equal(0, @integer.value) + end + + def test_reset + @integer.increment(5) + @integer.reset + assert_equal(0, @integer.value) + end end include IntegerTestCases