Sha256: ef0d94ea4ba79e45257a3c804241c91e4a56fbf41534b67a0c05752c7914c8b2

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require_relative '../../../spec_helper'

describe Arachni::Component::Options::Int do
    before( :all ) do
        @opt = Arachni::Component::Options::Int.new( '' )
    end

    describe '#valid?' do
        context 'when the value is valid' do
            it 'should return true' do
                @opt.valid?( '1' ).should be_true
                @opt.valid?( 1 ).should be_true
                @opt.valid?( 0 ).should be_true
                @opt.valid?( '0' ).should be_true
                @opt.valid?( '0xdd' ).should be_true
            end
        end
        context 'when the value is not valid' do
            it 'should return false' do
                @opt.valid?( 'sd' ).should be_false
                @opt.valid?( '4d' ).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( '0xdd' ).should == 221
            @opt.normalize( '5dd' ).should be_nil
            @opt.normalize( '5' ).should == 5
            @opt.normalize( 3 ).should == 3
        end
    end

    describe '#type' do
        it 'should return the option type as a string' do
            @opt.type.should == 'integer'
        end
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
arachni-0.4.1.3 spec/arachni/component/options/int_spec.rb
arachni-0.4.1.2 spec/arachni/component/options/int_spec.rb
arachni-0.4.1.1 spec/arachni/component/options/int_spec.rb
arachni-0.4.1 spec/arachni/component/options/int_spec.rb