Skip to content

Commit a624f3d

Browse files
author
André Mommert
committed
Rubocop issues fixed
1 parent a770f45 commit a624f3d

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

lib/meilisearch/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def reset_stop_words
386386
Models::Task.new(response, task_endpoint)
387387
end
388388

389-
### SETTINGS - DINSTINCT ATTRIBUTE
389+
### SETTINGS - DISTINCT ATTRIBUTE
390390

391391
def distinct_attribute
392392
http_get "/indexes/#{@uid}/settings/distinct-attribute"

spec/meilisearch/client/requests_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RSpec.describe 'MeiliSearch::Client requests' do
44
let(:key) { SecureRandom.uuid }
55

6-
before(:each) do
6+
before do
77
expect(MeiliSearch::Client).to receive(:post)
88
.with(kind_of(String), hash_including(body: "{\"primaryKey\":\"#{key}\",\"uid\":\"#{key}\"}"))
99
.and_call_original

spec/meilisearch/client/token_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def initialize(api_key)
5353
it 'decodes successfully using @api_key from instance' do
5454
expect do
5555
JWT.decode token, client_key, true, VERIFY_OPTIONS
56-
end.to_not raise_error
56+
end.not_to raise_error
5757
end
5858

5959
it 'tries to decode without the right signature raises a error' do
@@ -89,7 +89,7 @@ def initialize(api_key)
8989
it 'allows generate token with a nil expires_at' do
9090
expect do
9191
instance.generate_tenant_token('uid', search_rules, expires_at: nil)
92-
end.to_not raise_error
92+
end.not_to raise_error
9393
end
9494

9595
it 'decodes successfully the expires_at param' do
@@ -117,7 +117,7 @@ def initialize(api_key)
117117
it 'allows generate token without expires_at' do
118118
expect do
119119
instance.generate_tenant_token('uid', search_rules)
120-
end.to_not raise_error
120+
end.not_to raise_error
121121
end
122122
end
123123

spec/meilisearch/index/base_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
client.create_index('books').await
66

77
index = client.fetch_index('books')
8-
expect(index).to be_a(MeiliSearch::Index)
8+
expect(index).to be_a(described_class)
99
expect(index.uid).to eq('books')
1010
expect(index.created_at).to be_a(Time)
1111
expect(index.created_at).to be_within(60).of(Time.now)
@@ -59,7 +59,7 @@
5959
task.await
6060

6161
index = client.fetch_index('uid')
62-
expect(index).to be_a(MeiliSearch::Index)
62+
expect(index).to be_a(described_class)
6363
expect(index.uid).to eq('uid')
6464
expect(index.primary_key).to eq('new_primary_key')
6565
expect(index.fetch_primary_key).to eq('new_primary_key')
@@ -77,7 +77,7 @@
7777
task.await
7878

7979
index = client.fetch_index('books')
80-
expect(index).to be_a(MeiliSearch::Index)
80+
expect(index).to be_a(described_class)
8181
expect(index.uid).to eq('books')
8282
expect(index.primary_key).to eq('international_standard_book_number')
8383
expect(index.fetch_primary_key).to eq('international_standard_book_number')
@@ -111,7 +111,7 @@
111111
index = new_client.fetch_index('books')
112112
expect(index.options).to eq({ max_retries: 1, timeout: 2, convert_body?: true })
113113

114-
expect(MeiliSearch::Index).to receive(:get).with(
114+
expect(described_class).to receive(:get).with(
115115
"#{URL}/indexes/books",
116116
{
117117
headers: expected_headers,
@@ -139,7 +139,7 @@
139139
index = new_client.fetch_index('books')
140140
expect(index.options).to eq(options.merge({ convert_body?: true }))
141141

142-
expect(MeiliSearch::Index).to receive(:get).with(
142+
expect(described_class).to receive(:get).with(
143143
"#{URL}/indexes/books",
144144
{
145145
headers: expected_headers,
@@ -194,7 +194,7 @@
194194
task.await
195195

196196
index = client.fetch_index('uid')
197-
expect(index).to be_a(MeiliSearch::Index)
197+
expect(index).to be_a(described_class)
198198
expect(index.uid).to eq('uid')
199199
expect(index.primary_key).to eq('new_primary_key')
200200
expect(index.fetch_primary_key).to eq('new_primary_key')

spec/meilisearch/index/search/q_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,9 @@
7272
context 'with finite pagination params' do
7373
it 'responds with specialized fields' do
7474
response = index.search('coco', { page: 2, hits_per_page: 2 })
75-
7675
expect(response.keys).to contain_exactly(*FINITE_PAGINATED_SEARCH_RESPONSE_KEYS)
77-
end
7876

79-
it 'responds with specialized fields' do
8077
response = index.search('coco', { page: 2, hitsPerPage: 2 })
81-
8278
expect(response.keys).to contain_exactly(*FINITE_PAGINATED_SEARCH_RESPONSE_KEYS)
8379
end
8480
end

spec/meilisearch/index/search/vector_search.rb renamed to spec/meilisearch/index/search/vector_search_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
new_index = client.index('vector_test_search')
1515
new_index.add_documents(documents).await
1616

17-
expect(new_index.search('q', vector: [0, 1, 2])['hits']).not_to be_empty
17+
expect(new_index.search(vector: [9, 9, 9])['hits']).to be_empty
18+
expect(new_index.search('All Things Must Pass')['hits']).not_to be_empty
1819
end
1920
end

spec/meilisearch/models/task_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# frozen_string_literal: true
22

33
describe MeiliSearch::Models::Task do
4+
subject { described_class.new task_hash, endpoint }
5+
46
let(:new_index_uid) { random_uid }
57
let(:task_hash) { client.http_post '/indexes', { 'uid' => new_index_uid } }
68
let(:endpoint) { MeiliSearch::Task.new(URL, MASTER_KEY, client.options) }
79

8-
subject { described_class.new task_hash, endpoint }
9-
1010
let(:enqueued_endpoint) { instance_double(MeiliSearch::Task, task: task_hash) }
1111
let(:enqueued_task) { described_class.new task_hash, enqueued_endpoint }
1212

1313
let(:processing_endpoint) { instance_double(MeiliSearch::Task, task: task_hash.update('status' => 'processing')) }
1414
let(:processing_task) { described_class.new task_hash, processing_endpoint }
1515

1616
let(:logger) { instance_double(Logger, warn: nil) }
17+
1718
before { MeiliSearch::Utils.logger = logger }
1819
after { MeiliSearch::Utils.logger = nil }
1920

@@ -362,6 +363,7 @@
362363

363364
context 'when the task is already finished' do
364365
let(:endpoint) { instance_double(MeiliSearch::Task, task: task_hash, cancel_tasks: nil) }
366+
365367
before { task_hash['status'] = 'succeeded' }
366368

367369
it 'sends no request' do
@@ -374,6 +376,7 @@
374376

375377
context 'when the task is already cancelled' do
376378
let(:endpoint) { instance_double(MeiliSearch::Task, task: task_hash, cancel_tasks: nil) }
379+
377380
before { task_hash['status'] = 'cancelled' }
378381

379382
it 'sends no request' do

spec/meilisearch/utils_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
let(:logger) { instance_double(Logger, warn: nil) }
55

66
describe '.soft_deprecate' do
7-
before(:each) { described_class.logger = logger }
8-
after(:each) { described_class.logger = nil }
7+
before { described_class.logger = logger }
8+
after { described_class.logger = nil }
99

1010
it 'outputs a warning' do
1111
described_class.soft_deprecate('footballs', 'snowballs')
@@ -45,8 +45,8 @@
4545
end
4646

4747
describe '.transform_attributes' do
48-
before(:each) { described_class.logger = logger }
49-
after(:each) { described_class.logger = nil }
48+
before { described_class.logger = logger }
49+
after { described_class.logger = nil }
5050

5151
it 'transforms snake_case into camelCased keys' do
5252
data = described_class.transform_attributes({
@@ -143,8 +143,8 @@
143143
end
144144

145145
describe '.warn_on_non_conforming_attribute_names' do
146-
before(:each) { described_class.logger = logger }
147-
after(:each) { described_class.logger = nil }
146+
before { described_class.logger = logger }
147+
after { described_class.logger = nil }
148148

149149
it 'warns when using camelCase attributes' do
150150
attrs = { attributesToHighlight: ['field'] }

spec/meilisearch_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
RSpec.describe MeiliSearch do
44
it 'has a version number' do
5-
expect(MeiliSearch::VERSION).not_to be nil
5+
expect(MeiliSearch::VERSION).not_to be_nil
66
end
77

88
it 'has a qualified version number' do
9-
expect(MeiliSearch.qualified_version).to eq("Meilisearch Ruby (v#{MeiliSearch::VERSION})")
9+
expect(described_class.qualified_version).to eq("Meilisearch Ruby (v#{MeiliSearch::VERSION})")
1010
end
1111

1212
it 'raises an exception when it is impossible to connect' do
@@ -33,6 +33,6 @@
3333
new_client = MeiliSearch::Client.new(URL, MASTER_KEY)
3434

3535
expect(new_client.headers).to have_key('User-Agent')
36-
expect(new_client.headers['User-Agent']).to eq(MeiliSearch.qualified_version)
36+
expect(new_client.headers['User-Agent']).to eq(described_class.qualified_version)
3737
end
3838
end

0 commit comments

Comments
 (0)