Sha256: 1607e168da64ef45ad6bb7f8abbc40e0ed7abde8da81b9417ce8300d1c64abb3
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true RSpec.describe FiniteMachine::Subscribers do let(:listener) { double } it "checks if any subscribers exist" do subscribers = described_class.new expect(subscribers.empty?).to eq(true) subscribers.subscribe(listener) expect(subscribers.empty?).to eq(false) end it "allows to subscribe multiple listeners" do subscribers = described_class.new subscribers.subscribe(listener, listener) expect(subscribers.size).to eq(2) end it "returns index for the subscriber" do subscribers = described_class.new subscribers.subscribe(listener) expect(subscribers.index(listener)).to eql(0) end it "visits all subscribed listeners for the event" do subscribers = described_class.new subscribers.subscribe(listener) event = spy(:event) subscribers.visit(event) expect(event).to have_received(:notify).with(listener) end it "resets the subscribers" do subscribers = described_class.new subscribers.subscribe(listener) expect(subscribers.empty?).to eq(false) subscribers.reset expect(subscribers.empty?).to eq(true) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finite_machine-0.12.1 | spec/unit/subscribers_spec.rb |
finite_machine-0.12.0 | spec/unit/subscribers_spec.rb |