Sha256: 336b1121edc8b31d625b8ac9abee8f4c8d0c66522230d76d2c20a8336f675f32

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'
module Alf
  describe TupleComputation, "coerce" do

    subject{ TupleComputation.coerce(arg).evaluate(scope) }

    let(:scope) {
      Support::TupleScope.new(status: 10, who: "alf")
    }

    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 => ->(t){ t.who } }
      }
      let(:expected){
        {hello: "alf", :hello2 => "alf"}
      }
      it{ should eql(expected) }
    end

    describe "from a Hash with coercion" do
      let(:arg){
        {"hello" => :who}
      }
      let(:expected){
        {hello: "alf"}
      }
      it{ should eql(expected) }
    end

    describe "from a Tuple" do
      let(:arg){ Tuple(hello: TupleExpression.coerce(:who)) }
      let(:expected){ {hello: "alf"} }

      it{ should eql(expected) }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/tuple_computation/test_coerce.rb