Sha256: b073f182a1ecb516c8dcf3c98511871c12324f1a5ea2d61577d7c9dd4072e0dd

Contents?: true

Size: 959 Bytes

Versions: 5

Compression:

Stored size: 959 Bytes

Contents

require 'spec_helper'
module Alf
  module Engine
    describe SetAttr do

      it 'should work on an empty operand' do
        SetAttr.new([], TupleComputation[{}]).to_a.should eq([])
      end

      it 'should allow implementing UPDATE' do
        rel = [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        exp = [
          {:name => "JONES"},
          {:name => "SMITH"}
        ]
        comp = TupleComputation[:name => lambda{ name.upcase }]
        SetAttr.new(rel, comp).to_a.should eq(exp)
      end

      it 'should allow implementing EXTEND' do
        rel = [
          {:name => "Jones"},
          {:name => "Smith"}
        ]
        exp = [
          {:name => "Jones", :up => "JONES"},
          {:name => "Smith", :up => "SMITH"}
        ]
        comp = TupleComputation[:up => lambda{ name.upcase }]
        SetAttr.new(rel, comp).to_a.should eq(exp)
      end

    end
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-engine/test_set_attr.rb
alf-0.12.1 spec/unit/alf-engine/test_set_attr.rb
alf-0.12.0 spec/unit/alf-engine/test_set_attr.rb
alf-0.11.1 spec/unit/alf-engine/test_set_attr.rb
alf-0.11.0 spec/unit/alf-engine/test_set_attr.rb