Sha256: b2172fa1becb571631ab1ee6effbb57a1cf192bef203d37884c2fc6661eed843

Contents?: true

Size: 1001 Bytes

Versions: 4

Compression:

Stored size: 1001 Bytes

Contents

require 'spec_helper'
module Alf
  module Support
    describe TupleScope, "evaluate" do

      context 'with a simple TupleScope' do
        let(:scope){ TupleScope.new(:a => 1, :b => 2) }

        it "should allow a block" do
          scope.evaluate{ a }.should == 1
        end

        it 'should resolve DUM and DEE correctly' do
          scope.evaluate{ DUM }.should be_a(Relation)
        end
      end

      context 'when scopes are added at construction' do
        let(:scope){ TupleScope.new({:who => "world"}, [ HelpersInScope ]) }

        it 'has available helpers in scope' do
          scope.evaluate{ hello(who) }.should eq("Hello world!")
        end
      end

      context 'when scope has a parent' do
        let(:parent){ Scope.new [ HelpersInScope ] }
        let(:scope){ TupleScope.new({:here => "here"}, [  ], parent) }

        it 'has parent helpers in scope' do
          scope.evaluate{ hello(here) }.should eq("Hello here!")
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-support/tuple_scope/test_evaluate.rb
alf-core-0.14.0 spec/unit/alf-support/tuple_scope/test_evaluate.rb
alf-core-0.13.1 spec/unit/alf-support/tuple_scope/test_evaluate.rb
alf-core-0.13.0 spec/unit/alf-support/tuple_scope/test_evaluate.rb