Sha256: 8addca2f2c32eaed3fd6f7577f87a7dba0312338f3c9a0c4a19b21f269715c52

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

require 'spec_helper'
module Alf
  module Algebra
    describe Operand, '.coerce' do

      subject{ Operand.coerce(arg) }

      context "on a Symbol" do
        let(:arg){ :suppliers }

        it 'coerces it as a named operand' do
          subject.should be_a(Operand::Named)
          subject.name.should eq(:suppliers)
        end
      end

      context "on a Hash" do
        let(:arg){ {name: "Jones"} }

        it 'coerces it as a proxy operand on an array' do
          subject.should be_a(Operand::Proxy)
          subject.subject.should eq([ arg ])
        end
      end

      context "on a Tuple" do
        let(:arg){ Tuple(name: "Jones") }

        it 'coerces it as a proxy operand on an array' do
          subject.should be_a(Operand::Proxy)
          subject.subject.should eq([ arg ])
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-algebra/operand/test_coerce.rb