Sha256: b665390618f47207ae17cc4fd91157d3bde087e8312923df5c218cdd07ac5fe4

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

require 'spec_helper'
module Alf
  class Predicate
    describe Predicate, "qualify" do

      let(:p){ Predicate }

      subject{ predicate.qualify(qualifier) }

      let(:qualifier) { {:x => :t} }

      context 'on a full AST predicate' do
        let(:predicate){ p.in(:x, [2]) & p.eq(:y, 3) }

        it{ should eq(p.in(Factory.qualified_identifier(:t, :x), [2]) & p.eq(:y, 3)) }

        specify "it should tag expressions correctly" do
          subject.expr.should be_a(Sexpr)
          subject.expr.should be_a(Expr)
          subject.expr.should be_a(And)
        end
      end

      context 'on a predicate that contains natives' do
        let(:predicate){ p.in(:x, [2]) & p.native(lambda{}) }

        it 'raises an error' do
          lambda{
            subject
          }.should raise_error(NotSupportedError)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-predicate/predicate/test_qualify.rb