Sha256: d813e08b68825373abc6310045dcede8f421ea4ab9070611ebdd05173cfd2b13
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
require_relative '../../../spec_helper' describe Arachni::Component::Options::Enum do before( :all ) do @opt = Arachni::Component::Options::Enum.new( '', [ false, 'Blah', nil, %w(1 2 3)] ) end describe '#valid?' do context 'when the value is valid' do it 'should return true' do @opt.valid?( '1' ).should be_true end end context 'when the value is not valid' do it 'should return false' do @opt.valid?( '4' ).should be_false end end context 'when required but empty' do it 'should return false' do @opt.class.new( '', [true] ).valid?( nil ).should be_false end end end describe '#normalize' do it 'should convert the string input into a boolean value' do @opt.normalize( '5' ).should be_nil @opt.normalize( '3' ).should == '3' @opt.normalize( 3 ).should == '3' end end describe '#desc' do it 'should return a description including the acceptable values' do @opt.desc.include?( 'Blah' ).should be_true @opt.enums.each { |v| @opt.desc.include?( v ).should be_true } @opt.desc = 'boo' @opt.desc.include?( 'boo' ).should be_true @opt.desc.include?( 'Blah' ).should be_false end end describe '#type' do it 'should return the option type as a string' do @opt.type.should == 'enum' end end end
Version data entries
4 entries across 4 versions & 1 rubygems