Sha256: 8c0c4be8f02d84521bee91beee41a6c984afab99e0dc12904092fe06ee8c277f

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
module Alf
  module Operator
    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

7 entries across 7 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/operator/signature/test_install.rb
alf-0.12.1 spec/unit/alf-core/operator/signature/test_install.rb
alf-0.12.0 spec/unit/alf-core/operator/signature/test_install.rb
alf-0.11.1 spec/unit/alf-core/operator/signature/test_install.rb
alf-0.11.0 spec/unit/alf-core/operator/signature/test_install.rb
alf-0.10.1 spec/unit/operator/signature/test_install.rb
alf-0.10.0 spec/unit/operator/signature/test_install.rb