Sha256: fb2b78f40c7a5167bbd0ab14b01b99a64d7eca5c214dcd7ba7b11691934f518d

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
module Alf
  describe TupleComputation do

    let(:handle){ Tools::TupleHandle.new.set(:who => "alf") }
      
    describe "coerce" do
      subject{ TupleComputation.coerce(arg).evaluate(handle) }
      
      describe "from a TupleComputation" do
        let(:arg){ TupleComputation.new :hello => TupleExpression.coerce(:who) } 
        it{ should eql(:hello => "alf") } 
      end
        
      describe "from a Hash without coercion" do
        let(:arg){ 
          {:hello  => TupleExpression.coerce(:who),
           :hello2 => 2,
           :hello3 => lambda{ who } }
        }
        let(:expected){
          {:hello => "alf", :hello2 => 2, :hello3 => "alf"}
        }
        it{ should eql(expected) }
      end
        
      describe "from a Hash with coercion" do
        let(:arg){ 
          {"hello" => "who", "hello2" => "2"}
        }
        let(:expected){
          {:hello => "alf", :hello2 => 2}
        }
        it{ should eql(expected) }
      end
        
      describe "from an Array with coercions" do
        let(:arg){ ["hello", "who", "hello2", "2"] }
        let(:expected){
          {:hello => "alf", :hello2 => 2}
        }
        it{ should eql(expected) }
      end
    end
    
    describe "from_argv" do
      subject{ TupleComputation.from_argv(argv).evaluate(handle) }

      describe "from an Array with coercions" do
        let(:argv){ ["hello", "who", "hello2", "2"] }
        let(:expected){
          {:hello => "alf", :hello2 => 2}
        }
        it{ should eql(expected) }
      end
      
    end
        
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/types/test_tuple_computation.rb
alf-0.10.0 spec/unit/types/test_tuple_computation.rb