Sha256: a012f9a7738d621bac3ec8923d78ec2738e207db95af8067b8c3256381c2c725
Contents?: true
Size: 986 Bytes
Versions: 4
Compression:
Stored size: 986 Bytes
Contents
require 'spec_helper' module Alf module Engine describe Defaults do it 'should work on an empty operand' do Defaults.new(Leaf.new([]), TupleComputation[:id => 1]).to_a.should eq([]) end it 'should replace nil by the default value' do rel = Leaf.new [ {:name => "Jones"}, {:name => nil} ] exp = [ {:name => "Jones"}, {:name => "Smith"} ] Defaults.new(rel, TupleComputation[:name => "Smith"]).to_a.should eq(exp) end it 'should add missing attributes and allow computations' do rel = Leaf.new [ {:name => "Jones"}, {:name => "Smith"} ] exp = [ {:name => "Jones", :up => "JONES"}, {:name => "Smith", :up => "SMITH"} ] defs = TupleComputation[:up => lambda{ name.upcase }] Defaults.new(rel, defs).to_a.should eq(exp) end end end # module Engine end # module Alf
Version data entries
4 entries across 4 versions & 1 rubygems