Sha256: e73bfadf767a54d3c4e865d6087fd7164b5e81490eb3a5dd1721bcb47701bbb8

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'
module Alf
  module Algebra
    describe Signature, '#option_parser' do

      let(:clazz){ Class.new(Object) }
      let(:signature){
        Signature.new(clazz) do |s|
          s.option :allbut, Boolean,  true
          s.option :name,   AttrName, :autonum
        end
      }
      let(:receiver){ clazz.new }
      before{ signature.install }
      subject{ signature.option_parser(receiver) }

      specify "expected" do
        opt = OptionParser.new 
        opt.on("--allbut"){ receiver.send(:allbut=,true) }
        opt.on("--name=NAME"){|val| receiver.send(:name=,val) }
        opt.parse!(["--allbut","--name=world"])
        receiver.allbut.should be_true
        receiver.name.should eq(:world)
      end

      it { should be_a(OptionParser) }

      it "should install option values correctly" do
        subject.parse!(["--allbut","--name=world"])
        receiver.allbut.should be_true
        receiver.name.should eq(:world)
      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_option_parser.rb
alf-core-0.14.0 spec/unit/alf-algebra/support/signature/test_option_parser.rb
alf-core-0.13.1 spec/unit/alf-algebra/support/signature/test_option_parser.rb
alf-core-0.13.0 spec/unit/alf-algebra/support/signature/test_option_parser.rb