Sha256: 83213e845cd8ffb82842cbfdd5a8a5f1a6899db2b4af85473c6f33a29b69baa0

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

# encoding: utf-8

describe Informator::Event do

  subject(:event) { described_class.new type, :foo, [:bar], baz: :qux }

  let(:type) { "success" }

  describe ".new" do

    it { is_expected.to be_frozen }

  end # describe .new

  describe ".[]" do

    before { allow(described_class).to receive(:new) }

    it "builds the event" do
      expect(described_class).to receive(:new).with(:foo, :bar, :baz)
      described_class[:foo, :bar, :baz]
    end

  end # describe .new

  describe "#type" do

    subject { event.type }
    it { is_expected.to eql type.to_sym }

  end # describe #type

  describe "#messages" do

    subject { event.messages }
    it { is_expected.to eql %w(foo bar) }

  end # describe #messages

  describe "#attributes" do

    subject { event.attributes }
    it { is_expected.to eq(baz: :qux) }

  end # describe #attributes

  describe "#==" do

    subject { event == other }

    context "to event with the same type and attributes" do

      let(:other) { Class.new(described_class).new type, baz: :qux }
      it { is_expected.to eql true }

    end # context

    context "to event with another type" do

      let(:other) { described_class.new :error, baz: :qux }
      it { is_expected.to eql false }

    end # context

    context "to event with other attributes" do

      let(:other) { described_class.new :success, baz: "qux" }
      it { is_expected.to eql false }

    end # context

    context "to non-event" do

      let(:other) { :foo }
      it { is_expected.to eql false }

    end # context

  end # describe #==

end # describe Informator::Event

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
informator-0.1.0 spec/unit/informator/event_spec.rb