Sha256: a43ac822ed61bb517d543d94e1e2a68439f38dcb33cad18594f5496598edf8d2

Contents?: true

Size: 923 Bytes

Versions: 18

Compression:

Stored size: 923 Bytes

Contents

shared_examples_for 'MetasploitDataModels::Search::Visitor::Includes#visit with #children' do
  let(:children) do
    2.times.collect { |n|
      double("Child #{n}")
    }
  end

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

  it 'should visit each child' do
    # needed for call to visit subject
    expect(visitor).to receive(:visit).with(node).and_call_original

    children.each do |child|
      expect(visitor).to receive(:visit).with(child).and_return([])
    end

    visit
  end

  it 'should return Array of all child visits' do
    child_visits = []

    expect(visitor).to receive(:visit).with(node).and_call_original

    children.each_with_index do |child, i|
      child_visit = ["Visited Child #{i}"]
      allow(visitor).to receive(:visit).with(child).and_return(child_visit)
      child_visits.concat(child_visit)
    end

    expect(visit).to eq(child_visits)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
metasploit_data_models-1.2.10 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.9 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.8 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.7 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.6 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.5 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.4 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.3 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.2 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-0.24.4 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.1 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.2.0 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.1.0 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.0.1 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-1.0.0 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-0.24.3 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-0.24.2 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb
metasploit_data_models-0.24.1.pre.rspec.pre.3.pre.1 spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb