Sha256: 34cfcacbcdd55241477fe04c8750273eaaabc1e8738d42b57cefe3a936c15292

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 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 equal(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

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.0 spec/unit/axiom/tuple/predicate_spec.rb