Sha256: 9784fc850d5f67cc1d48a0ceff90a851cc53e85495869af4a7c1c16569274e00

Contents?: true

Size: 1.29 KB

Versions: 30

Compression:

Stored size: 1.29 KB

Contents

RSpec.describe Metasploit::Model::Search::Operation::Boolean, type: :model do
  context 'CONSTANTS' do
    context 'FORMATTED_VALUE_TO_VALUE' do
      subject(:formatted_value_to_value) do
        described_class::FORMATTED_VALUE_TO_VALUE
      end

      it "maps 'false' to false" do
        expect(formatted_value_to_value['false']).to eq(false)
      end

      it "maps 'true' to true" do
        expect(formatted_value_to_value['true']).to eq(true)
      end
    end
  end

  context 'validations' do
    it { is_expected.to allow_value(false).for(:value) }
    it { is_expected.to allow_value(true).for(:value) }
    it { is_expected.not_to allow_value(nil).for(:value) }
  end

  context '#value' do
    subject(:value) do
      operation.value
    end

    let(:operation) do
      described_class.new(:value => formatted_value)
    end

    context "with 'false'" do
      let(:formatted_value) do
        'false'
      end

      it { is_expected.to eq(false) }
    end

    context "with 'true'" do
      let(:formatted_value) do
        'true'
      end

      it { is_expected.to eq(true) }
    end

    context 'with other' do
      let(:formatted_value) do
        'unknown'
      end

      it 'should return value unparsed' do
        expect(value).to eq(formatted_value)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
metasploit-model-5.0.2 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-5.0.1 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-5.0.0 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.6 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.5 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.4 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.3 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.2 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.1 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-4.0.0 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.1.4 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.1.3 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.1.2 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.1.1 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.1.0 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-3.0.0 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-2.0.4 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-2.0.3 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-2.0.2 spec/app/models/metasploit/model/search/operation/boolean_spec.rb
metasploit-model-2.0.1 spec/app/models/metasploit/model/search/operation/boolean_spec.rb