Sha256: 94dc93733b4327d455dbce4554ffe7d12b898001a969342383718d9bcd350062
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
require 'spec_helper' describe 'Veritas::Algebra::Restriction::Methods#restrict' do let(:klass) { Relation } let(:object) { klass.new([ [ :id, Integer ] ], [ [ 1 ] ].each) } context 'with predicate arguments' do subject { object.restrict(predicate) } let(:predicate) { object[:id].eq(1) } it { should be_kind_of(Algebra::Restriction) } it 'sets the predicate' do subject.predicate.should equal(predicate) end it 'behaves the same as Enumerable#select' do should == object.select { |tuple| tuple[:id] == 1 } end end context 'with a block' do subject { object.restrict(&block) } let(:block) { lambda { |relation| relation[:id].eq(1) } } it { should be_kind_of(Algebra::Restriction) } it 'sets the predicate' do subject.predicate.should eql(block.call(object)) end it 'behaves the same as Enumerable#select' do should == object.select { |tuple| tuple[:id] == 1 } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.2 | spec/unit/veritas/algebra/restriction/methods/restrict_spec.rb |