|
17 | 17 | expect(index).to be_a(MeiliSearch::Index) |
18 | 18 | expect(index.uid).to eq(@uid1) |
19 | 19 | expect(index.primary_key).to be_nil |
| 20 | + expect(index.fetch_primary_key).to be_nil |
20 | 21 | end |
21 | 22 |
|
22 | 23 | it 'creates an index with primary-key' do |
23 | 24 | index = @client.create_index(@uid2, primaryKey: @primary_key) |
24 | 25 | expect(index).to be_a(MeiliSearch::Index) |
25 | 26 | expect(index.uid).to eq(@uid2) |
26 | 27 | expect(index.primary_key).to eq(@primary_key) |
| 28 | + expect(index.fetch_primary_key).to eq(@primary_key) |
27 | 29 | end |
28 | 30 |
|
29 | 31 | it 'creates an index with uid in options - should not take it into account' do |
30 | 32 | index = @client.create_index(@uid3, primaryKey: @primary_key, uid: 'wrong') |
31 | 33 | expect(index).to be_a(MeiliSearch::Index) |
32 | 34 | expect(index.uid).to eq(@uid3) |
33 | 35 | expect(index.primary_key).to eq(@primary_key) |
| 36 | + expect(index.fetch_primary_key).to eq(@primary_key) |
34 | 37 | end |
35 | 38 |
|
36 | 39 | it 'creates an new index with get_or_create_index method' do |
37 | 40 | index = @client.get_or_create_index(@uid4) |
| 41 | + expect(index).to be_a(MeiliSearch::Index) |
38 | 42 | expect(@client.indexes.count).to eq(4) |
39 | | - expect(@client.index(@uid4).uid).to eq(index.uid) |
40 | | - expect(@client.index(@uid4).uid).to eq(@uid4) |
41 | | - expect(@client.index(@uid4).primary_key).to be_nil |
| 43 | + expect(@client.fetch_index(@uid4).uid).to eq(index.uid) |
| 44 | + expect(@client.fetch_index(@uid4).uid).to eq(@uid4) |
| 45 | + expect(@client.fetch_index(@uid4).primary_key).to be_nil |
| 46 | + expect(@client.fetch_index(@uid4).primary_key).to eq(index.primary_key) |
42 | 47 | end |
43 | 48 |
|
44 | 49 | it 'creates an new index with get_or_create_index method and a primary-key' do |
45 | 50 | index = @client.get_or_create_index(@uid5, primaryKey: 'title') |
| 51 | + expect(index).to be_a(MeiliSearch::Index) |
46 | 52 | expect(@client.indexes.count).to eq(5) |
47 | | - expect(@client.index(@uid5).uid).to eq(index.uid) |
48 | | - expect(@client.index(@uid5).uid).to eq(@uid5) |
49 | | - expect(@client.index(@uid5).primary_key).to eq(index.primary_key) |
50 | | - expect(@client.index(@uid5).primary_key).to eq('title') |
| 53 | + expect(@client.fetch_index(@uid5).uid).to eq(index.uid) |
| 54 | + expect(@client.fetch_index(@uid5).uid).to eq(@uid5) |
| 55 | + expect(@client.fetch_index(@uid5).primary_key).to eq(index.primary_key) |
| 56 | + expect(@client.fetch_index(@uid5).primary_key).to eq('title') |
51 | 57 | end |
52 | 58 |
|
53 | 59 | it 'get an already existing index with get_or_create_index method' do |
54 | 60 | index = @client.get_or_create_index(@uid5) |
| 61 | + expect(index).to be_a(MeiliSearch::Index) |
55 | 62 | expect(@client.indexes.count).to eq(5) |
56 | | - expect(@client.index(@uid5).uid).to eq(index.uid) |
57 | | - expect(@client.index(@uid5).uid).to eq(@uid5) |
58 | | - expect(@client.index(@uid5).primary_key).to eq('title') |
| 63 | + expect(@client.fetch_index(@uid5).uid).to eq(index.uid) |
| 64 | + expect(@client.fetch_index(@uid5).uid).to eq(@uid5) |
| 65 | + expect(@client.fetch_index(@uid5).primary_key).to eq('title') |
| 66 | + expect(@client.fetch_index(@uid5).primary_key).to eq(index.primary_key) |
59 | 67 | end |
60 | 68 |
|
61 | 69 | it 'fails to create an index with an uid already taken' do |
|
78 | 86 | expect(uids).to contain_exactly(@uid1, @uid2, @uid3, @uid4, @uid5) |
79 | 87 | end |
80 | 88 |
|
81 | | - it 'shows a specific index' do |
82 | | - response = @client.show_index(@uid2) |
83 | | - expect(response).to be_a(Hash) |
84 | | - expect(response['uid']).to eq(@uid2) |
85 | | - expect(response['primaryKey']).to eq(@primary_key) |
| 89 | + it 'fetch a specific index' do |
| 90 | + response = @client.fetch_index(@uid2) |
| 91 | + expect(response).to be_a(MeiliSearch::Index) |
| 92 | + expect(response.uid).to eq(@uid2) |
| 93 | + expect(response.primary_key).to eq(@primary_key) |
| 94 | + expect(response.fetch_primary_key).to eq(@primary_key) |
86 | 95 | end |
87 | 96 |
|
88 | 97 | it 'returns an index object based on uid' do |
89 | 98 | index = @client.index(@uid2) |
90 | 99 | expect(index).to be_a(MeiliSearch::Index) |
91 | 100 | expect(index.uid).to eq(@uid2) |
| 101 | + expect(index.primary_key).to be_nil |
| 102 | + expect(index.fetch_primary_key).to eq(@primary_key) |
92 | 103 | expect(index.primary_key).to eq(@primary_key) |
93 | 104 | end |
94 | 105 |
|
95 | 106 | it 'deletes index' do |
96 | 107 | expect(@client.delete_index(@uid1)).to be_nil |
97 | | - expect { @client.show_index(@uid1) }.to raise_index_not_found_meilisearch_api_error |
| 108 | + expect { @client.fetch_index(@uid1) }.to raise_index_not_found_meilisearch_api_error |
98 | 109 | expect(@client.delete_index(@uid2)).to be_nil |
99 | | - expect { @client.show_index(@uid2) }.to raise_index_not_found_meilisearch_api_error |
| 110 | + expect { @client.fetch_index(@uid2) }.to raise_index_not_found_meilisearch_api_error |
100 | 111 | expect(@client.delete_index(@uid3)).to be_nil |
101 | | - expect { @client.show_index(@uid3) }.to raise_index_not_found_meilisearch_api_error |
| 112 | + expect { @client.fetch_index(@uid3) }.to raise_index_not_found_meilisearch_api_error |
102 | 113 | expect(@client.delete_index(@uid4)).to be_nil |
103 | | - expect { @client.show_index(@uid4) }.to raise_index_not_found_meilisearch_api_error |
| 114 | + expect { @client.fetch_index(@uid4) }.to raise_index_not_found_meilisearch_api_error |
104 | 115 | expect(@client.delete_index(@uid5)).to be_nil |
105 | | - expect { @client.show_index(@uid5) }.to raise_index_not_found_meilisearch_api_error |
| 116 | + expect { @client.fetch_index(@uid5) }.to raise_index_not_found_meilisearch_api_error |
106 | 117 | expect(@client.indexes.count).to eq(0) |
107 | 118 | end |
108 | | - |
109 | | - it 'works with method aliases' do |
110 | | - expect(@client.method(:index) == @client.method(:get_index)).to be_truthy |
111 | | - end |
112 | 119 | end |
0 commit comments