Sha256: 95e7f91bcaf2c8fe2a7546663a182575b2c515f604914f569b853fa2c232c058
Contents?: true
Size: 845 Bytes
Versions: 26
Compression:
Stored size: 845 Bytes
Contents
class TestInstrumenter class << self def subscribe(callback, filter=nil, &block) # create test instrumenter instance instrumenter = TestInstrumenter.new do |name, payload| if filter callback.call(name, payload) if name =~ filter else callback.call(name, payload) end end # hook up this instrumenter in the context of the spec # (assuming called from RSpec binding) spec_binding = block.binding.eval('self') spec_binding.instance_exec do allow(Taskinator).to receive(:instrumenter).and_return(instrumenter) end yield end end attr_reader :callback def initialize(&block) @callback = block end def instrument(event, payload={}) @callback.call(event, payload) yield(payload) if block_given? end end
Version data entries
26 entries across 26 versions & 1 rubygems