module Resilient::Test::CircuitBreakerRegistryInterface

Public Instance Methods

test_fetch() click to toggle source
# File lib/resilient/test/circuit_breaker_registry_interface.rb, line 12
def test_fetch
  key = "foo"
  value = "bar".freeze

  assert_raises(KeyError) { @object.fetch(key) }
  assert_equal value, @object.fetch(key) { value }
  assert_equal value, @object.fetch(key)
  assert @object.fetch(key).equal?(value)
end
test_reset() click to toggle source
# File lib/resilient/test/circuit_breaker_registry_interface.rb, line 22
def test_reset
  original_foo = @object.fetch("foo") { Object.new }
  original_bar = @object.fetch("bar") { Object.new }

  assert_nil @object.reset

  foo = @object.fetch("foo") { Object.new }
  bar = @object.fetch("bar") { Object.new }

  # assert that the objects before and after reset are not the same object
  refute original_foo.equal?(foo)
  refute original_bar.equal?(bar)
end
test_reset_empty_registry() click to toggle source
# File lib/resilient/test/circuit_breaker_registry_interface.rb, line 36
def test_reset_empty_registry
  assert_nil @object.reset
end
test_responds_to_fetch() click to toggle source
# File lib/resilient/test/circuit_breaker_registry_interface.rb, line 4
def test_responds_to_fetch
  assert_respond_to @object, :fetch
end
test_responds_to_reset() click to toggle source
# File lib/resilient/test/circuit_breaker_registry_interface.rb, line 8
def test_responds_to_reset
  assert_respond_to @object, :reset
end