Sha256: 161c3e34a15294310541ff91835f54b09ee766f59d4559bfffa0e40fb00c360b

Contents?: true

Size: 945 Bytes

Versions: 9

Compression:

Stored size: 945 Bytes

Contents

require 'spec_helper'
module Alf
  module Engine
    describe Coerce do

      it 'should work on an empty operand' do
        Coerce.new([], Heading[:price => Float]).to_a.should eq([])
      end

      let(:operand){[
          {:name => "Jones", :price => "12.0"},
          {:name => "Smith", :price => "-10.0"}
      ]}

      it 'should work on a non empty operand' do
        exp = [
          {:name => "Jones", :price => 12.0},
          {:name => "Smith", :price => -10.0}
        ]
        heading = Heading[:name => String, :price => Float]
        Coerce.new(operand, heading).to_a.should eq(exp)
      end

      it 'should not project on the heading' do
        exp = [
          {:name => "Jones", :price => 12.0},
          {:name => "Smith", :price => -10.0}
        ]
        heading = Heading[:price => Float]
        Coerce.new(operand, heading).to_a.should eq(exp)
      end

    end
  end # module Engine
end # module Alf

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-engine/test_coerce.rb
alf-core-0.14.0 spec/unit/alf-engine/test_coerce.rb
alf-core-0.13.1 spec/unit/alf-engine/test_coerce.rb
alf-core-0.13.0 spec/unit/alf-engine/test_coerce.rb
alf-0.12.2 spec/unit/alf-engine/test_coerce.rb
alf-0.12.1 spec/unit/alf-engine/test_coerce.rb
alf-0.12.0 spec/unit/alf-engine/test_coerce.rb
alf-0.11.1 spec/unit/alf-engine/test_coerce.rb
alf-0.11.0 spec/unit/alf-engine/test_coerce.rb