Sha256: 532135afa976ed5a92102654763103d2a9e7fca370f4b167df07392d35da892d

Contents?: true

Size: 1.42 KB

Versions: 38

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

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

  context 'validations' do
    context 'operator' do
      it { should 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(:each) 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
              errors.should_not include(error)
            end
          end

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

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

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

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

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
metasploit-model-1.0.0.pre.rails.pre.4.0 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.30.0 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.30.0-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.29.2 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.29.2-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.29.0 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.29.0-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.28.0 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.28.0-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.28.0.pre.engine.pre.requires spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.4 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.4-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.3 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.3-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.2 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.2-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.1 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.1-java spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.0 spec/app/models/metasploit/model/search/operation/base_spec.rb
metasploit-model-0.27.0-java spec/app/models/metasploit/model/search/operation/base_spec.rb