Sha256: 0991bfed4e85d97c3e74635dd884ea156f91caa5bd25dd6e1fd0b57159abb3f3
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Optimizer::Function::Connective::Disjunction::OptimizableToInclusion, '#optimizable?' do subject { object.optimizable? } let(:attribute) { Attribute::Integer.new(:id) } let(:connective) { left.or(right) } let(:object) { described_class.new(connective) } before do expect(object.operation).to be_kind_of(Function::Connective::Disjunction) end context 'when the operands are optimizable' do context 'when the left and right are equality predicates' do let(:left) { attribute.eq(2) } let(:right) { attribute.eq(1) } it { should be(true) } end context 'when the left is an equality predicate and the right is an inclusion predicate' do let(:left) { attribute.eq(2) } let(:right) { attribute.include([1, 3]) } it { should be(true) } end context 'when the left is an inclusion predicate and the right is an equality predicate' do let(:left) { attribute.include([2, 3]) } let(:right) { attribute.eq(1) } it { should be(true) } end context 'when the left and right are inclusion predicatess' do let(:left) { attribute.include([2, 3]) } let(:right) { attribute.include([1, 3]) } it { should be(true) } end end context 'when the operands are not optimizable' do context 'when the left is an inequality predicate and the right is an equality predicate' do let(:left) { attribute.ne(1) } let(:right) { attribute.eq(2) } it { should be(false) } end context 'when the left is an exclusion predicate and the right is an equality predicate' do let(:left) { attribute.exclude([1, 3]) } let(:right) { attribute.eq(2) } it { should be(false) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems