class ActiveSupport::Notifications::InstrumenterTest

Attributes

instrumenter[R]
notifier[R]
payload[R]

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File activesupport/test/notifications/instrumenter_test.rb, line 23
def setup
  super
  @notifier     = TestNotifier.new
  @instrumenter = Instrumenter.new @notifier
  @payload = { foo: Object.new }
end
test_finish() click to toggle source
# File activesupport/test/notifications/instrumenter_test.rb, line 53
def test_finish
  instrumenter.finish("foo", payload)
  assert_equal [["foo", instrumenter.id, payload]], notifier.finishes
  assert_predicate notifier.starts, :empty?
end
test_instrument() click to toggle source
# File activesupport/test/notifications/instrumenter_test.rb, line 30
def test_instrument
  called = false
  instrumenter.instrument("foo", payload) {
    called = true
  }

  assert called
end
test_instrument_yields_the_payload_for_further_modification() click to toggle source
# File activesupport/test/notifications/instrumenter_test.rb, line 39
def test_instrument_yields_the_payload_for_further_modification
  assert_equal 2, instrumenter.instrument("awesome") { |p| p[:result] = 1 + 1 }
  assert_equal 1, notifier.finishes.size
  name, _, payload = notifier.finishes.first
  assert_equal "awesome", name
  assert_equal Hash[result: 2], payload
end
test_start() click to toggle source
# File activesupport/test/notifications/instrumenter_test.rb, line 47
def test_start
  instrumenter.start("foo", payload)
  assert_equal [["foo", instrumenter.id, payload]], notifier.starts
  assert_predicate notifier.finishes, :empty?
end