Sha256: cb15fbf192d42074aa022efb704836c81706abd2ea4d28d90e38f009beb79814

Contents?: true

Size: 1.19 KB

Versions: 56

Compression:

Stored size: 1.19 KB

Contents

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
    visitor.should_receive(:visit).with(node).and_call_original

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

    visit
  end

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

    children.each_with_index do |child, i|
      child_visit = Arel::Nodes::Equality.new(i, i)
      visitor.stub(: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

    arel_pair.should be_a arel_class

    expect([arel_pair.left, arel_pair.right]).to match_array(child_visits)
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
metasploit_data_models-0.24.5 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.24.1 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-1.0.0.pre.rails.pre.4.0b spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-1.0.0.pre.rails.pre.4.0a spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.24.0 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.3.pre.autoload spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.2 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.2-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.1 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.1-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.0 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.23.0-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.8 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.8-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.7 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.7-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.6 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.6-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.5 spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb
metasploit_data_models-0.22.5-java spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb