Sha256: 7ae2e7fa78093bd004d89bc6beb504098d7ade4abe5cfc5f0f74b2faea349ef9

Contents?: true

Size: 803 Bytes

Versions: 1

Compression:

Stored size: 803 Bytes

Contents

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

    let(:scope) {
      Support::TupleScope.new(:status => 10)
    }

    subject{ TupleExpression.coerce(arg) }

    describe "with nil" do
      let(:arg){ nil }
      specify{ lambda{ subject }.should raise_error(ArgumentError) }
    end

    describe "with a Symbol" do
      let(:arg){ :status }
      it { should be_a(TupleExpression) }
      specify{
        subject.evaluate(scope).should eql(10)
        subject.source.should eq("t.status")
      }
    end

    describe "with a Proc" do
      let(:arg){ lambda{ :hello } }
      it { should be_a(TupleExpression) }
      specify{
        subject.evaluate(scope).should eql(:hello)
        subject.source.should be_nil
      }
    end

  end # TupleExpression
end # Alf

Version data entries

1 entries across 1 versions & 1 rubygems

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