class Notifications::InstrumentationTest
Public Instance Methods
test_event_is_pushed_even_without_block()
click to toggle source
# File activesupport/test/notifications_test.rb, line 240 def test_event_is_pushed_even_without_block instrument(:awesome, payload: "notifications") assert_equal 1, @events.size assert_equal :awesome, @events.last.name assert_equal Hash[payload: "notifications"], @events.last.payload end
test_instrument_publishes_when_exception_is_raised()
click to toggle source
# File activesupport/test/notifications_test.rb, line 226 def test_instrument_publishes_when_exception_is_raised begin instrument(:awesome, payload: "notifications") do raise "FAIL" end rescue RuntimeError => e assert_equal "FAIL", e.message end assert_equal 1, @events.size assert_equal Hash[payload: "notifications", exception: ["RuntimeError", "FAIL"], exception_object: e], @events.last.payload end
test_instrument_returns_block_result()
click to toggle source
# File activesupport/test/notifications_test.rb, line 195 def test_instrument_returns_block_result assert_equal 2, instrument(:awesome) { 1 + 1 } end
test_instrument_yields_the_payload_for_further_modification()
click to toggle source
# File activesupport/test/notifications_test.rb, line 199 def test_instrument_yields_the_payload_for_further_modification assert_equal 2, instrument(:awesome) { |p| p[:result] = 1 + 1 } assert_equal 1, @events.size assert_equal :awesome, @events.first.name assert_equal Hash[result: 2], @events.first.payload end
test_instrumenter_exposes_its_id()
click to toggle source
# File activesupport/test/notifications_test.rb, line 206 def test_instrumenter_exposes_its_id assert_equal 20, ActiveSupport::Notifications.instrumenter.id.size end
test_nested_events_can_be_instrumented()
click to toggle source
# File activesupport/test/notifications_test.rb, line 210 def test_nested_events_can_be_instrumented instrument(:awesome, payload: "notifications") do instrument(:wot, payload: "child") do 1 + 1 end assert_equal 1, @events.size assert_equal :wot, @events.first.name assert_equal Hash[payload: "child"], @events.first.payload end assert_equal 2, @events.size assert_equal :awesome, @events.last.name assert_equal Hash[payload: "notifications"], @events.last.payload end