Sha256: ddee81bcfbe2dbf54e6f9d146634380bde5cb299a25a05f34855d8c3ab4bcfdd
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
# encoding: utf-8 require 'spec_helper' 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
4 entries across 4 versions & 1 rubygems