|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | | -describe MeiliSearch::Rails::MultiSearchResult do |
4 | | - it 'is enumerable' do |
5 | | - expect(described_class).to include(Enumerable) |
6 | | - end |
7 | | - |
| 3 | +describe MeiliSearch::Rails::MultiSearchResult do # rubocop:todo RSpec/FilePath |
8 | 4 | let(:raw_results) do |
9 | 5 | [ |
10 | 6 | { 'indexUid' => 'books_index', |
11 | 7 | 'hits' => [{ 'name' => 'Steve Jobs', 'id' => '3', 'author' => 'Walter Isaacson', 'premium' => nil, 'released' => nil, 'genre' => nil }], |
12 | | - 'query' => 'Steve', 'processingTimeMs' => 0, 'limit' => 20, 'offset' => 0, 'estimatedTotalHits' => 1 |
13 | | - }, |
| 8 | + 'query' => 'Steve', 'processingTimeMs' => 0, 'limit' => 20, 'offset' => 0, 'estimatedTotalHits' => 1 }, |
14 | 9 | { 'indexUid' => 'products_index', |
15 | 10 | 'hits' => [{ 'id' => '4', 'href' => 'ebay', 'name' => 'palm pixi plus' }], |
16 | | - 'query' => 'palm', 'processingTimeMs' => 0, 'limit' => 1, 'offset' => 0, 'estimatedTotalHits' => 2 |
17 | | - }, |
| 11 | + 'query' => 'palm', 'processingTimeMs' => 0, 'limit' => 1, 'offset' => 0, 'estimatedTotalHits' => 2 }, |
18 | 12 | { 'indexUid' => 'color_index', |
19 | 13 | 'hits' => [ |
20 | 14 | { 'name' => 'black', 'id' => '5', 'short_name' => 'bla', 'hex' => 0 }, |
21 | 15 | { 'name' => 'blue', 'id' => '4', 'short_name' => 'blu', 'hex' => 255 } |
22 | 16 | ], |
23 | | - 'query' => 'bl', 'processingTimeMs' => 0, 'limit' => 20, 'offset' => 0, 'estimatedTotalHits' => 2 |
24 | | - } |
| 17 | + 'query' => 'bl', 'processingTimeMs' => 0, 'limit' => 20, 'offset' => 0, 'estimatedTotalHits' => 2 } |
25 | 18 | ] |
26 | 19 | end |
27 | 20 |
|
| 21 | + it 'is enumerable' do |
| 22 | + expect(described_class).to include(Enumerable) |
| 23 | + end |
| 24 | + |
28 | 25 | context 'with index name keys' do |
29 | 26 | subject(:result) { described_class.new(searches, raw_results) } |
30 | 27 |
|
|
48 | 45 | it 'enumerates through the hits of each result with #each_result' do |
49 | 46 | expect(result.each_result).to be_an(Enumerator) |
50 | 47 | expect(result.each_result).to contain_exactly( |
51 | | - [ 'books_index', contain_exactly( |
52 | | - a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs')) ], |
53 | | - [ 'products_index', contain_exactly( |
54 | | - a_hash_including('name' => 'palm pixi plus')) ], |
55 | | - [ 'color_index', contain_exactly( |
56 | | - a_hash_including('name' => 'blue', 'short_name' => 'blu'), |
57 | | - a_hash_including('name' => 'black', 'short_name' => 'bla')) ] |
| 48 | + ['books_index', contain_exactly( |
| 49 | + a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs') |
| 50 | + )], |
| 51 | + ['products_index', contain_exactly( |
| 52 | + a_hash_including('name' => 'palm pixi plus') |
| 53 | + )], |
| 54 | + ['color_index', contain_exactly( |
| 55 | + a_hash_including('name' => 'blue', 'short_name' => 'blu'), |
| 56 | + a_hash_including('name' => 'black', 'short_name' => 'bla') |
| 57 | + )] |
58 | 58 | ) |
59 | 59 | end |
60 | 60 |
|
|
69 | 69 | end |
70 | 70 |
|
71 | 71 | it 'aliases as #to_ary' do |
72 | | - expect(subject.method(:to_ary).original_name).to eq :to_a |
| 72 | + expect(result.method(:to_ary).original_name).to eq :to_a |
73 | 73 | end |
74 | 74 | end |
75 | 75 |
|
|
0 commit comments