Sha256: c7d413745e768d1da2bdacf2abd8149d95b0607bc9534dd9ee43c6110904ef74

Contents?: true

Size: 1.26 KB

Versions: 50

Compression:

Stored size: 1.26 KB

Contents

RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search*::Group::Base' do |options={}|
  options.assert_valid_keys(:arel_class)

  arel_class = options.fetch(:arel_class)

  let(:children) do
    2.times.collect { |n|
      double("Group Child #{n}")
    }
  end

  let(:node) do
    node_class.new(
        :children => children
    )
  end

  it 'should visit each child' do
    expect(visitor).to receive(:visit).with(node).and_call_original

    children.each do |child|
      expect(visitor).to receive(:visit).with(child).and_return(Arel::Nodes::Equality.new(1, 1))
    end

    visit
  end

  it "should combine children AREL with #{arel_class}" do
    allow(visitor).to receive(:visit).with(node).and_call_original
    child_visits = []

    children.each_with_index do |child, i|
      child_visit = Arel::Nodes::Equality.new(i, i)
      allow(visitor).to receive(:visit).with(child).and_return(child_visit)
      child_visits << child_visit
    end

    root = visit

    if root.is_a? Arel::Nodes::Grouping
      arel_pair = root.expr
    else
      arel_pair = root
    end

    expect(arel_pair).to be_a arel_class

    expect(arel_pair.left).to eq(child_visits[0])
    expect(arel_pair.right).to eq(child_visits[1])
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
wg-metasploit_data_models-4.1.4.02 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.5 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.4 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.3 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.2 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.1 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-6.0.0 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.6 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.5 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.4 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.3 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.2 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.1 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-5.0.0 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.1.4 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.1.3 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.1.2 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.1.1 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.1.0 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-4.0.2 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb