Sha256: eb841a74ffbd432f277b8f94c090bb2be8a4e3767fc4e123bfb2c57bc81b1eea

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe Metasploit::Model::Search::Operator::Union 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::Union }

    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

3 entries across 3 versions & 1 rubygems

Version Path
metasploit-model-0.24.1-java spec/app/models/metasploit/model/search/operator/union_spec.rb
metasploit-model-0.24.1 spec/app/models/metasploit/model/search/operator/union_spec.rb
metasploit-model-0.24.1.pre.semantic.pre.versioning.pre.2.pre.0 spec/app/models/metasploit/model/search/operator/union_spec.rb