Sha256: 1e5fd0065204b38d12d81ab44b7ba428601be512d5e25f7dfbe432e57a66fba8

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe Arachni::Component::Options::Base do
    include_examples 'component_option'

    describe '#normalize' do
        it 'returns the value as is' do
            expect(described_class.new( '', value: 'blah' ).normalize).to eq('blah')
        end

        context 'when no #value is set' do
            it 'returns #default' do
                expect(described_class.new( '', default: 'test' ).normalize).to eq('test')
            end
        end
    end

    describe '#valid?' do
        context 'when the option is required' do
            context 'and the value is not empty' do
                it 'returns true' do
                    expect(described_class.new( '', required: true, value: 'stuff' ).valid?).to be_truthy
                end
            end

            context 'and the value is nil' do
                it 'returns false' do
                    expect(described_class.new( '', required: true ).valid?).to be_falsey
                end
            end
        end

        context 'when the option is not required' do
            context 'and the value is not empty' do
                it 'returns true' do
                    expect(described_class.new( '', value: 'true' ).valid?).to be_truthy
                end
            end

            context 'and the value is empty' do
                it 'returns true' do
                    expect(described_class.new( '' ).valid?).to be_truthy
                end
            end
        end
    end

    describe '#type' do
        it 'returns the option type' do
            expect(described_class.new( '' ).type).to eq(:abstract)
        end
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
arachni-1.6.1.3 spec/arachni/component/options/base_spec.rb
arachni-1.6.1.2 spec/arachni/component/options/base_spec.rb
arachni-1.6.1.1 spec/arachni/component/options/base_spec.rb
arachni-1.6.1 spec/arachni/component/options/base_spec.rb
arachni-1.6.0 spec/arachni/component/options/base_spec.rb
arachni-1.5.1 spec/arachni/component/options/base_spec.rb
arachni-1.5 spec/arachni/component/options/base_spec.rb
arachni-1.4 spec/arachni/component/options/base_spec.rb
arachni-1.3.2 spec/arachni/component/options/base_spec.rb
arachni-1.3.1 spec/arachni/component/options/base_spec.rb
arachni-1.3 spec/arachni/component/options/base_spec.rb