Sha256: 015512fa3f26fc869e73cc1787dc6883f915b534111cf7f5f1bffe24de27e660
Contents?: true
Size: 980 Bytes
Versions: 1
Compression:
Stored size: 980 Bytes
Contents
require 'spec_helper' RSpec.describe 'Subscribing to instrumentation events' do subject(:notifications) { Dry::Monitor::Notifications.new(:app) } before do Dry::Monitor::Notifications.register_event(:sql, { name: 'rom[sql]' }) end describe '#instrument' do it 'allows subscribing via block' do captured = [] payload = { query: 'SELECT 1 FROM users' } notifications.subscribe(:sql) do |event| captured << [event.id, event[:query]] end notifications.instrument(:sql, payload) expect(captured).to eql([[:sql, 'SELECT 1 FROM users']]) end it 'allows instrumenting via block' do captured = [] payload = { query: 'SELECT 1 FROM users' } notifications.subscribe(:sql) do |event| captured << [event.id, event[:query]] end notifications.instrument(:sql, payload) do payload end expect(captured).to eql([[:sql, 'SELECT 1 FROM users']]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-monitor-0.1.0 | spec/integration/instrumentation_spec.rb |