提交 1b7ef40d 编写于 作者: A Ali Ibrahim

Update AS::Notifications::Instrumenter#instrument

  * Update #instrument to make passing a block optional. This will let users
    leverage #instrument for messaging in addition to instrumentation.
上级 f4086080
......@@ -20,7 +20,7 @@ def instrument(name, payload = {})
# some of the listeners might have state
listeners_state = start name, payload
begin
yield payload
yield payload if block_given?
rescue Exception => e
payload[:exception] = [e.class.name, e.message]
payload[:exception_object] = e
......
......@@ -44,6 +44,12 @@ def test_instrument_yields_the_payload_for_further_modification
assert_equal Hash[result: 2], payload
end
def test_instrument_works_without_a_block
instrumenter.instrument("no.block", payload)
assert_equal 1, notifier.finishes.size
assert_equal "no.block", notifier.finishes.first.first
end
def test_start
instrumenter.start("foo", payload)
assert_equal [["foo", instrumenter.id, payload]], notifier.starts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册