Sha256: feb91e3424c485093888d74570ed04009e665dae8fa2251902974c4f49b6616a

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8

module Selector

  describe Selector::Array do

    let(:left)  { described_class.new [:foo, :bar] }
    let(:right) { described_class.new [:bar, :baz] }

    describe ".new" do

      subject { left }

      it { is_expected.to be_kind_of Collection }

      it { is_expected.to be_frozen }

      it "sets the attribute" do
        expect(subject.attribute).to eql(Set.new [:foo, :bar])
      end

    end # describe .new

    describe "#&" do

      subject { left & right }

      context "array" do

        it "returns the array" do
          expect(subject).to be_kind_of described_class
        end

        it "composes the attributes" do
          expect(subject.attribute).to eql(Set.new [:bar])
        end

      end # context

      context "non-array" do

        let(:right) { Condition.new }
        it { is_expected.to be_kind_of(And) }

      end # context

    end # describe #&

    describe "#|" do

      subject { left | right }

      context "array" do

        it "returns the array" do
          expect(subject).to be_kind_of described_class
        end

        it "composes the attributes" do
          expect(subject.attribute).to eql(Set.new [:foo, :bar, :baz])
        end

      end # context

      context "non-array" do

        let(:right) { Condition.new }
        it { is_expected.to be_kind_of(Or) }

      end # context

    end # describe #&

  end # describe Selector::Array

end # module Selector

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selector-0.0.3 spec/unit/selector/array_spec.rb
selector-0.0.2 spec/unit/selector/array_spec.rb
selector-0.0.1 spec/unit/selector/array_spec.rb