Sha256: d1ec753f5145453da53051ee962324bb1badaac87ba263db895a958c967a1c9d

Contents?: true

Size: 1.93 KB

Versions: 22

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'
class Predicate
  describe And, "and_split" do

    let(:tautology){ Factory.tautology  }

    subject{ predicate.and_split(list) }

    context 'when attributes on one side' do
      let(:predicate){ Factory.eq(:x, 2) & Factory.eq(:y, 3) }

      context 'when fully covered' do
        let(:list){ [:x, :y] }

        it{ should eq([predicate, tautology]) }
      end

      context 'when not covered at all' do
        let(:list){ [:name] }

        it{ should eq([tautology, predicate]) }
      end

      context 'when partially covered' do
        let(:list){ [:x] }

        it{ should eq([Factory.eq(:x, 2), Factory.eq(:y, 3)]) }
      end
    end

    context 'when attributes on both sides' do
      let(:predicate){ Factory.eq(:x, 2) & Factory.eq(:y, :z) }

      context 'when fully covered' do
        let(:list){ [:x, :y, :z] }

        it{ should eq([predicate, tautology]) }
      end

      context 'when not covered at all' do
        let(:list){ [:name] }

        it{ should eq([tautology, predicate]) }
      end

      context 'when partially covered but split-able' do
        let(:list){ [:x] }

        it{ should eq([Factory.eq(:x, 2), Factory.eq(:y, :z)]) }
      end

      context 'when partially covered but split-able (2)' do
        let(:list){ [:y] }

        it{ should eq([Factory.eq(:y, :z), Factory.eq(:x, 2)]) }
      end

      context 'when partially covered but not split-able' do
        let(:list){ [:x, :y] }

        it{ should eq([predicate, tautology]) }
      end
    end

    context 'with a native on one side' do
      let(:left) { Factory.eq(:x, 2)       }
      let(:right){ Factory.native(->(t){}) }
      let(:predicate){ left & right }

      context 'when fully covered' do
        let(:list){ [:x, :y, :z] }

        it{ should eq([predicate, tautology]) }
      end

      context 'when not covered' do
        let(:list){ [:y] }

        it{ should eq([right, left]) }
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
predicate-2.8.0 spec/nodes/and/test_and_split.rb
predicate-2.7.1 spec/nodes/and/test_and_split.rb
predicate-2.7.0 spec/nodes/and/test_and_split.rb
predicate-2.6.0 spec/nodes/and/test_and_split.rb
predicate-2.5.0 spec/nodes/and/test_and_split.rb
predicate-2.4.0 spec/nodes/and/test_and_split.rb
predicate-2.3.3 spec/nodes/and/test_and_split.rb
predicate-2.3.2 spec/nodes/and/test_and_split.rb
predicate-2.3.1 spec/nodes/and/test_and_split.rb
predicate-2.3.0 spec/nodes/and/test_and_split.rb
predicate-2.2.1 spec/nodes/and/test_and_split.rb
predicate-2.2.0 spec/nodes/and/test_and_split.rb
predicate-2.1.0 spec/nodes/and/test_and_split.rb
predicate-2.0.1 spec/nodes/and/test_and_split.rb
predicate-2.0.0 spec/nodes/and/test_and_split.rb
predicate-1.3.4 spec/nodes/and/test_and_split.rb
predicate-1.3.3 spec/nodes/and/test_and_split.rb
predicate-1.3.2 spec/nodes/and/test_and_split.rb
predicate-1.3.1 spec/nodes/and/test_and_split.rb
predicate-1.3.0 spec/nodes/and/test_and_split.rb