Sha256: eba8445cf4c7b3c62df86d8431852de7f1f472256a460ce0c2f699b71801bac2

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Tuple, '#predicate' do
  subject { object.predicate }

  context 'when the header is empty' do
    let(:header) { Relation::Header.new            }
    let(:object) { described_class.new(header, []) }

    it_should_behave_like 'an idempotent method'

    it 'returns a tautology' do
      should be(Function::Proposition::Tautology.instance)
    end
  end

  context 'when the header contains one attribute' do
    let(:header) { Relation::Header.coerce([[:id, Integer]]) }
    let(:object) { described_class.new(header, [1])          }

    it_should_behave_like 'an idempotent method'

    it { should be_kind_of(Function) }

    it 'returns an equality match' do
      should eql(header[:id].eq(1))
    end
  end

  context 'when the header contains two or more attribute' do
    let(:header) { Relation::Header.coerce([[:id, Integer], [:name, String]]) }
    let(:object) { described_class.new(header, [1, 'Dan Kubb'])               }

    it_should_behave_like 'an idempotent method'

    it { should be_kind_of(Function) }

    it 'returns a conjunction of equality matches' do
      should eql(header[:id].eq(1).and(header[:name].eq('Dan Kubb')))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/tuple/predicate_spec.rb
axiom-0.1.1 spec/unit/axiom/tuple/predicate_spec.rb