Skip to content

Commit 5e7924d

Browse files
Merge #316
316: Create a helper module to reduce test duplication r=brunoocasali a=brunoocasali The general idea is to change tests from this: ```rb it 'searches with index with searchableAttributes setting' do response = index.update_searchable_attributes(['title', 'info.comment']) index.wait_for_task(response['uid']) response = index.add_documents(documents) index.wait_for_task(response['uid']) response = index.search('An awesome') expect(response['hits'].count).to eq(1) end ``` to this: ```rb it 'searches with index with searchableAttributes setting' do index.update_searchable_attributes(['title', 'info.comment']).then(&method(:wait_for_it)) index.add_documents(documents).then(&method(:wait_for_it)) response = index.search('An awesome') expect(response['hits'].count).to eq(1) end ``` or this: ```rb it 'searches with index with searchableAttributes setting' do wait_for_it index.update_searchable_attributes(['title', 'info.comment']) wait_for_it index.add_documents(documents) response = index.search('An awesome') expect(response['hits'].count).to eq(1) end ``` Co-authored-by: Bruno Casali <[email protected]>
2 parents 71b5fe3 + 3efa106 commit 5e7924d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130

131131
# Helpers
132132
config.include IndexesHelpers
133+
config.include TaskHelpers
133134
config.include ExceptionsHelpers
134135
config.include DumpsHelpers
135136
end

spec/support/task_helpers.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module TaskHelpers
4+
def wait_for_it(task)
5+
raise('The param `task` does not have an uid key.') unless task.key?('uid')
6+
7+
client.wait_for_task(task['uid'])
8+
end
9+
end

0 commit comments

Comments
 (0)