Sha256: ce1cd205d5fe7308418b8303b2ae77ef770053e7f37dc31c2f83f91d7e577657

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Hashmake::ArgSpec do
  it 'should raise ArgumentError if :reqd is false and no :default value is given' do
    hash = {
      :reqd => false, :key => :some_variable, :type => String
    }
    
    lambda { Hashmake::ArgSpec.new hash }.should raise_error(ArgumentError)
  end
  
  it 'should not raise ArgumentError if :reqd is false and a :default value is given' do
    hash = {
      :reqd => false, :key => :some_variable, :type => String, :default => ""
    }
    
    lambda { Hashmake::ArgSpec.new hash }.should_not raise_error(ArgumentError)
  end

  it 'should not raise ArgumentError if valid container is given' do
    Hashmake::ArgSpec::CONTAINERS.each do |container|
      hash = {
        :reqd => true, :key => :stuff, :type => String, :container => container
      }
      
      lambda { Hashmake::ArgSpec.new hash }.should_not raise_error(ArgumentError)      
    end
  end
  
  it 'should raise ArgumentError if invalid container is given' do
    hash = {
      :reqd => true, :key => :stuff, :type => String, :container => Fixnum
    }
    
    lambda { Hashmake::ArgSpec.new hash }.should raise_error(ArgumentError)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hashmake-0.1.9 spec/arg_spec_spec.rb
hashmake-0.1.8 spec/arg_spec_spec.rb
hashmake-0.1.7 spec/arg_spec_spec.rb
hashmake-0.1.6 spec/arg_spec_spec.rb
hashmake-0.1.5 spec/arg_spec_spec.rb