|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -RSpec.describe MeiliSearch::Client do |
| 3 | +RSpec.describe 'MeiliSearch::Client - Indexes' do |
4 | 4 | before(:all) do |
5 | 5 | @client = MeiliSearch::Client.new($URL, $MASTER_KEY) |
6 | 6 | clear_all_indexes(@client) |
7 | 7 | @uid1 = 'uid1' |
8 | 8 | @uid2 = 'uid2' |
9 | | - @uid3 = 'uid3' |
10 | 9 | @primary_key = 'objectId' |
11 | 10 | end |
12 | 11 |
|
|
17 | 16 | expect(index.primary_key).to be_nil |
18 | 17 | end |
19 | 18 |
|
20 | | - it 'creates an index without primary-key as an Hash' do |
21 | | - index = @client.create_index(uid: @uid2) |
22 | | - expect(index).to be_a(MeiliSearch::Index) |
23 | | - expect(index.uid).to eq(@uid2) |
24 | | - expect(index.primary_key).to be_nil |
25 | | - end |
26 | | - |
27 | 19 | it 'creates an index with primary-key' do |
28 | | - index = @client.create_index(uid: @uid3, primaryKey: @primary_key) |
| 20 | + index = @client.create_index(@uid2, primaryKey: @primary_key) |
29 | 21 | expect(index).to be_a(MeiliSearch::Index) |
30 | | - expect(index.uid).to eq(@uid3) |
| 22 | + expect(index.uid).to eq(@uid2) |
31 | 23 | expect(index.primary_key).to eq(@primary_key) |
32 | 24 | end |
33 | 25 |
|
|
46 | 38 | it 'gets list of indexes' do |
47 | 39 | response = @client.indexes |
48 | 40 | expect(response).to be_a(Array) |
49 | | - expect(response.count).to eq(3) |
| 41 | + expect(response.count).to eq(2) |
50 | 42 | uids = response.map { |elem| elem['uid'] } |
51 | | - expect(uids).to contain_exactly(@uid1, @uid2, @uid3) |
| 43 | + expect(uids).to contain_exactly(@uid1, @uid2) |
52 | 44 | end |
53 | 45 |
|
54 | 46 | it 'shows a specific index' do |
55 | | - response = @client.show_index(@uid3) |
| 47 | + response = @client.show_index(@uid2) |
56 | 48 | expect(response).to be_a(Hash) |
57 | | - expect(response['uid']).to eq(@uid3) |
| 49 | + expect(response['uid']).to eq(@uid2) |
58 | 50 | expect(response['primaryKey']).to eq(@primary_key) |
59 | 51 | end |
60 | 52 |
|
61 | 53 | it 'returns an index object based on uid' do |
62 | | - index = @client.index(@uid3) |
| 54 | + index = @client.index(@uid2) |
63 | 55 | expect(index).to be_a(MeiliSearch::Index) |
64 | | - expect(index.uid).to eq(@uid3) |
| 56 | + expect(index.uid).to eq(@uid2) |
65 | 57 | expect(index.primary_key).to eq(@primary_key) |
66 | 58 | end |
67 | 59 |
|
|
70 | 62 | expect { @client.show_index(@uid1) }.to raise_meilisearch_http_error_with(404) |
71 | 63 | expect(@client.delete_index(@uid2)).to be_nil |
72 | 64 | expect { @client.show_index(@uid2) }.to raise_meilisearch_http_error_with(404) |
73 | | - expect(@client.delete_index(@uid3)).to be_nil |
74 | | - expect { @client.show_index(@uid3) }.to raise_meilisearch_http_error_with(404) |
75 | 65 | expect(@client.indexes.count).to eq(0) |
76 | 66 | end |
77 | 67 |
|
|
0 commit comments