Sha256: 9b0d2399d736a214a4554f621eee21f7bb972963f9409da07318b99eee249663

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
module Alf
  module Algebra
    describe Signature, '.install' do
      
      let(:clazz){ Class.new(Object) }
      subject{ signature.install }
      
      describe "on an empty signature" do
        let(:signature){ Signature.new(clazz) }
        it{ should eq({}) }
        specify{
          lambda{ subject }.should_not raise_error
        }
      end
      
      describe "on a non empty signature" do

        let(:signature){ 
          Signature.new(clazz) do |s|
            s.argument :attrname, AttrName
            s.argument :ordering, Ordering
            s.option   :allbut,   Boolean, true
          end 
        }

        it{ should eq(:allbut => true) }

        it "should have arguments installed as attr accessors" do
          subject
          inst = clazz.new
          inst.should respond_to(:attrname)
          inst.send(:"attrname=", :hello)
          inst.attrname.should eq(:hello)
        end
   
        it "should have options installed as attr accessors" do
          subject
          inst = clazz.new
          inst.should respond_to(:allbut)
          inst.send(:"allbut=", true)
          inst.allbut.should be_true
        end

        it "should apply auto-coercion" do
          subject
          inst = clazz.new
          inst.send(:"allbut=", "true")
          inst.allbut.should be_true
        end

      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-algebra/support/signature/test_install.rb
alf-core-0.14.0 spec/unit/alf-algebra/support/signature/test_install.rb
alf-core-0.13.1 spec/unit/alf-algebra/support/signature/test_install.rb
alf-core-0.13.0 spec/unit/alf-algebra/support/signature/test_install.rb