Skip to content

Commit

Permalink
Small Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kyewei committed Nov 12, 2015
1 parent 4896c3c commit 0ccf771
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/semian/circuit_breaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/semian/simple_integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Integer #:nodoc:
attr_accessor :value

def initialize
@value = 0
reset
end

def increment(val = 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/semian/simple_sliding_window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions test/simple_integer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class TestSimpleInteger < MiniTest::Unit::TestCase

def setup
@integer = CLASS.new
@integer.value = 0
end

def teardown
Expand All @@ -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)
Expand All @@ -28,14 +26,23 @@ def test_access_value
end

def test_increment
@integer.value = 0
@integer.increment(4)
assert_equal(4, @integer.value)
@integer.increment
assert_equal(5, @integer.value)
@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
Expand Down

0 comments on commit 0ccf771

Please sign in to comment.