Sha256: 0bbc64558bc30c18153825ade118fb26eed2c3987964954186e948e00751ceae

Contents?: true

Size: 1.44 KB

Versions: 22

Compression:

Stored size: 1.44 KB

Contents

RSpec.describe Metasploit::Model::Search::Operation::Base, type: :model do
  subject(:operation) do
    described_class.new
  end

  context 'validations' do
    context 'operator' do
      it { is_expected.to validate_presence_of(:operator) }

      context 'valid' do
        let(:errors) do
          operation.errors[:operator]
        end

        let(:error) do
          I18n.translate('errors.messages.invalid')
        end


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

        before(:example) do
          operation.valid?
        end

        context 'with operator' do
          let(:operator) do
            double('Operator', :valid? => valid)
          end

          context 'with valid' do
            let(:valid) do
              true
            end

            it 'should not record error on operator' do
              expect(errors).not_to include(error)
            end
          end

          context 'without valid' do
            let(:valid) do
              false
            end

            it 'should record error on operator' do
              expect(errors).to include(error)
            end
          end
        end

        context 'without operator' do
          let(:operator) do
            nil
          end

          it 'should not record error on operator' do
            expect(errors).not_to include(error)
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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