Sha256: 866d9a7314470fe882eabc6d6b05d78edf06f96b417d919ec8a8397452f2a7e0

Contents?: true

Size: 1.67 KB

Versions: 35

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Metasploit::Model::Search::Operator::Group::Base do
  subject(:operator) do
    described_class.new
  end

  let(:formatted_value) do
    'formatted_value'
  end

  context '#children' do
    subject(:children) do
      operator.children(formatted_value)
    end

    it 'should be abstract' do
      expect {
        children
      }.to raise_error(NotImplementedError)
    end
  end

  context '#operate_on' do
    subject(:operation) do
      operator.operate_on(formatted_value)
    end

    #
    # lets
    #

    let(:children) do
      [
          invalid_child,
          valid_child
      ]
    end

    let(:valid_child) do
      double('Valid Child', valid?: true)
    end

    let(:invalid_child) do
      double('Invalid Child', valid?: false)
    end

    #
    # Callbacks
    #

    before(:each) do
      operator.stub(:children => children)
    end

    it { should be_a Metasploit::Model::Search::Operation::Group::Base }

    context 'children' do
      subject(:operation_children) do
        operation.children
      end

      it 'rejected invalid children' do
        expect(operation_children).not_to include(invalid_child)
      end

      it 'includes valid children' do
        expect(operation_children).to include(valid_child)
      end
    end

    context 'operator' do
      subject(:operation_operator) do
        operation.operator
      end

      it 'should be the operator itself' do
        operation_operator.should == operator
      end
    end

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

      it 'should be formatted value' do
        value.should == formatted_value
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

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