Sha256: fb1ad5587606d288a312e19420210ed7810c6aaccf539e50366b02b76694dadb

Contents?: true

Size: 1.65 KB

Versions: 38

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe Metasploit::Model::Search::With do
  let(:base_class) do
    described_class = self.described_class

    Class.new do
      include described_class
    end
  end

  context 'search_with' do
    subject(:search_with_operator) do
      base_class.search_with operator_class, options
    end

    let(:options) do
      {
          a: 1,
          b: 2
      }
    end

    let(:operator) do
      double(
          'Operator',
          :name => 'op',
          :valid! => nil
      )
    end

    let(:operator_class) do
      double(
          'Operator Class',
          :new => operator
      )
    end

    it 'should pass given options to operator_class.new' do
      operator_class.should_receive(:new).with(
          hash_including(options)
      ).and_return(operator)

      search_with_operator
    end

    it 'should merge :klass into options passed to operator.new' do
      operator_class.should_receive(:new).with(
          hash_including(
              :klass => base_class
          )
      )

      search_with_operator
    end

    it 'should validate operator' do
      operator_class.stub(:new).and_return(operator)

      operator.should_receive(:valid!)

      search_with_operator
    end

    it 'should add operator to search_with_operator_by_name' do
      search_with_operator

      base_class.search_with_operator_by_name[operator.name].should == operator
    end
  end

  context 'search_with_operator_by_name' do
    subject(:search_with_operator_by_name) do
      base_class.search_with_operator_by_name
    end

    it 'should default to empty Hash' do
      search_with_operator_by_name.should == {}
    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/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.30.0 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.30.0-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.29.2 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.29.2-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.29.0 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.29.0-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.28.0 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.28.0-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.28.0.pre.engine.pre.requires spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.4 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.4-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.3 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.3-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.2 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.2-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.1 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.1-java spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.0 spec/lib/metasploit/model/search/with_spec.rb
metasploit-model-0.27.0-java spec/lib/metasploit/model/search/with_spec.rb