Module: Resilient::Test::CircuitBreakerRegistryInterface

Defined in:
lib/resilient/test/circuit_breaker_registry_interface.rb

Instance Method Summary collapse

Instance Method Details

#test_fetchObject



12
13
14
15
16
17
18
19
20
# 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_resetObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# 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_registryObject



36
37
38
# File 'lib/resilient/test/circuit_breaker_registry_interface.rb', line 36

def test_reset_empty_registry
  assert_nil @object.reset
end

#test_responds_to_fetchObject



4
5
6
# 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_resetObject



8
9
10
# File 'lib/resilient/test/circuit_breaker_registry_interface.rb', line 8

def test_responds_to_reset
  assert_respond_to @object, :reset
end