Module: Sentiero::Reporter::TestHelper

Extended by:
TestHelper
Included in:
TestHelper
Defined in:
lib/sentiero/reporter/test_helper.rb

Overview

Test-suite support for asserting what the reporter would have sent. Not loaded by default: require "sentiero/reporter/test_helper".

Instance Method Summary collapse

Instance Method Details

#capture_notificationsObject

Runs the block with a synchronous in-memory transport, restores the previous transport, and returns deliveries as [path, payload] pairs.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sentiero/reporter/test_helper.rb', line 14

def capture_notifications
  recorder = TestTransport.new
  previous_transport = Reporter.configuration.transport
  previous_async = Reporter.configuration.async
  Reporter.configure do |c|
    c.transport = recorder
    c.async = false
  end
  yield
  recorder.deliveries
ensure
  Reporter.configure do |c|
    c.transport = previous_transport
    c.async = previous_async
  end
end