Sha256: 5189cd9a7faf7fcb94a5d530e33719a307c3b52004df88de9d18df9dc4e4b1b8

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Restriction::Methods, '#restrict' do
  let(:described_class) { Relation                                                  }
  let(:object)          { described_class.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }
  let(:block)           { lambda { |relation| relation[:id].eq(1) }                 }

  subject { object.restrict(&block) }

  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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/algebra/restriction/methods/restrict_spec.rb