summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/file_finder.rb
blob: 984a06ccd1aec8ce0bf973f643f80adb5ea6888c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

shared_examples 'file finder' do
  let(:query) { 'files' }
  let(:search_results) { subject.find(query) }

  it 'finds by name' do
    blob = search_results.find { |blob| blob.filename == expected_file_by_name }

    expect(blob.filename).to eq(expected_file_by_name)
    expect(blob).to be_a(Gitlab::Search::FoundBlob)
    expect(blob.ref).to eq(subject.ref)
    expect(blob.data).not_to be_empty
  end

  it 'finds by content' do
    blob = search_results.find { |blob| blob.filename == expected_file_by_content }

    expect(blob.filename).to eq(expected_file_by_content)
    expect(blob).to be_a(Gitlab::Search::FoundBlob)
    expect(blob.ref).to eq(subject.ref)
    expect(blob.data).not_to be_empty
  end
end