summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/file_finder.rb
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-06-04 13:57:51 +0200
committerAlessio Caiazza <acaiazza@gitlab.com>2018-06-04 13:57:51 +0200
commit8ffcaf3b85fdf716ffeacf4e9d4c89b922de50b9 (patch)
tree2e6acfa369e3e659ef4c6afb9290ad122a8fea5c /spec/support/shared_examples/file_finder.rb
parent1841da16abe864b3dae19636fee9e9bbe9a01b56 (diff)
parent23ae072ba2d601a3639a32f5a29302c430106bb8 (diff)
downloadgitlab-ce-11-0-stable-prepare-rc2.tar.gz
Merge branch 'master' into 11-0-stable-prepare-rc211-0-stable-prepare-rc2
Diffstat (limited to 'spec/support/shared_examples/file_finder.rb')
-rw-r--r--spec/support/shared_examples/file_finder.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/shared_examples/file_finder.rb b/spec/support/shared_examples/file_finder.rb
new file mode 100644
index 00000000000..ef144bdf61c
--- /dev/null
+++ b/spec/support/shared_examples/file_finder.rb
@@ -0,0 +1,21 @@
+shared_examples 'file finder' do
+ let(:query) { 'files' }
+ let(:search_results) { subject.find(query) }
+
+ it 'finds by name' do
+ filename, blob = search_results.find { |_, blob| blob.filename == expected_file_by_name }
+ expect(filename).to eq(expected_file_by_name)
+ expect(blob).to be_a(Gitlab::SearchResults::FoundBlob)
+ expect(blob.ref).to eq(subject.ref)
+ expect(blob.data).not_to be_empty
+ end
+
+ it 'finds by content' do
+ filename, blob = search_results.find { |_, blob| blob.filename == expected_file_by_content }
+
+ expect(filename).to eq(expected_file_by_content)
+ expect(blob).to be_a(Gitlab::SearchResults::FoundBlob)
+ expect(blob.ref).to eq(subject.ref)
+ expect(blob.data).not_to be_empty
+ end
+end