Sha256: d0a478fec4c097de8a4dc5554a51108a9af44eb96f1b337b301eaaeb77b9ffa6

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require "spec_helper"

RSpec.describe PubsubNotifier do
  let(:user)   { User.new }
  let(:member) { Member.new }

  describe "#publish_notifier" do
    it "calls success method on subscribed classes" do
      expect_any_instance_of(AdminNotifier).to receive(:success).once
      expect_any_instance_of(UserNotifier).to receive(:success).once
      user.broadcast(:success)
    end

    it "calls logger methods on subscribed classes" do
      expect_any_instance_of(Logger).to receive(:debug).exactly(4).times
      member.broadcast(:success)
      member.broadcast(:failure)
    end

    it "calls only_admin methods on subscribed classes" do
      expect_any_instance_of(AdminNotifier).to receive(:only_admin).once
      expect_any_instance_of(UserNotifier).not_to receive(:only_admin).once
      member.broadcast(:only_admin)
    end

    it "calls only_user methods on subscribed classes" do
      expect_any_instance_of(UserNotifier).to receive(:only_user).once
      expect_any_instance_of(AdminNotifier).not_to receive(:only_user).once
      member.broadcast(:only_user)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pubsub_notifier-0.1.1 spec/pubsub_notifier_spec.rb
pubsub_notifier-0.1.0 spec/pubsub_notifier_spec.rb