Sha256: e8f1e4ad4c60ec489964f490ac010404d6e5c4523fe321d05403d48d40302c00
Contents?: true
Size: 1.03 KB
Versions: 26
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' module Startback describe Bus::Memory do subject{ Bus::Memory::Sync.new } it 'allows emiting an receiving' do seen = nil subject.listen("user_changed") do |evt| seen = evt end subject.emit(Event.new("user_changed", {id: 12})) expect(seen).to be_a(Event) expect(seen.type).to eql("user_changed") expect(seen.data.to_h).to eql({id: 12}) end it 'allows mixin Symbol vs. String for event type' do seen = nil subject.listen(:user_changed) do |evt| seen = evt end subject.emit(Event.new(:user_changed, {id: 12})) expect(seen).to be_a(Event) expect(seen.type).to eql("user_changed") expect(seen.data.to_h).to eql({id: 12}) end it 'raises emit errors synchronously' do subject.listen("user_changed") do |evt| raise "An error occured" end expect { subject.emit(Event.new("user_changed", {id: 12})) }.to raise_error("An error occured") end end end
Version data entries
26 entries across 26 versions & 1 rubygems