Sha256: a1239744f33e7dc5211b7a5656464b2d4e6ad6af1de5f9668ba26e7028a4afed

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
module Alf
  describe AttrName do
    
    it "should allow normal names" do
      (AttrName === :city).should be_true
    end
    
    it "should allow underscores" do
      (AttrName === :my_city).should be_true
    end
    
    it "should allow numbers" do
      (AttrName === :city2).should be_true
    end
    
    it "should not allow strange attribute names" do
      (AttrName === "$$$".to_sym).should be_false
    end
    
    describe "from_argv" do
      
      subject{ AttrName.from_argv(argv, opts) }
      
      describe "with a String" do
        let(:argv){ %w{hello} }
        let(:opts) {{}}
        it{ should eq(:hello) }
      end

      describe "with nothing but a default" do
        let(:argv){ %w{} }
        let(:opts){ {:default => :hello} }
        it{ should eq(:hello) }
      end

      describe "with nothing and no default" do
        let(:argv){ %w{} }
        let(:opts){ {} }
        specify{ lambda{subject}.should raise_error(ArgumentError) }
      end

      describe "with more than one string" do
        let(:argv){ %w{hello world} }
        let(:opts){ {} }
        specify{ lambda{subject}.should raise_error(ArgumentError) }
      end
      
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/types/test_attr_name.rb
alf-0.10.0 spec/unit/types/test_attr_name.rb