|
60 | 60 | ) |
61 | 61 | end |
62 | 62 |
|
| 63 | + describe '#each' do |
| 64 | + let(:logger) { instance_double('Logger', info: nil) } |
| 65 | + |
| 66 | + before do |
| 67 | + allow(MeiliSearch::Rails).to receive(:logger).and_return(logger) |
| 68 | + end |
| 69 | + |
| 70 | + it 'has the same behavior as #each_result' do |
| 71 | + expect(result.each).to be_an(Enumerator) |
| 72 | + expect(result.each).to contain_exactly( |
| 73 | + ['books_index', contain_exactly( |
| 74 | + a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs') |
| 75 | + )], |
| 76 | + ['products_index', contain_exactly( |
| 77 | + a_hash_including('name' => 'palm pixi plus') |
| 78 | + )], |
| 79 | + ['color_index', contain_exactly( |
| 80 | + a_hash_including('name' => 'blue', 'short_name' => 'blu'), |
| 81 | + a_hash_including('name' => 'black', 'short_name' => 'bla') |
| 82 | + )] |
| 83 | + ) |
| 84 | + end |
| 85 | + |
| 86 | + it 'warns about changed behavior' do |
| 87 | + result.each(&:to_s) |
| 88 | + |
| 89 | + expect(logger).to have_received(:info).with(a_string_including('#each on a multi search now iterates through grouped results.')) |
| 90 | + end |
| 91 | + end |
| 92 | + |
| 93 | + describe '#each_hit' do |
| 94 | + let(:logger) { instance_double('Logger', warn: nil) } |
| 95 | + |
| 96 | + before do |
| 97 | + allow(MeiliSearch::Rails).to receive(:logger).and_return(logger) |
| 98 | + end |
| 99 | + |
| 100 | + it 'warns about deprecation' do |
| 101 | + result.each_hit(&:to_s) |
| 102 | + |
| 103 | + expect(logger).to have_received(:warn).with(a_string_including('Flattening multi search')) |
| 104 | + end |
| 105 | + end |
| 106 | + |
63 | 107 | describe '#to_a' do |
| 108 | + let(:logger) { instance_double('Logger', warn: nil) } |
| 109 | + |
| 110 | + before do |
| 111 | + allow(MeiliSearch::Rails).to receive(:logger).and_return(logger) |
| 112 | + end |
| 113 | + |
64 | 114 | it 'returns the hits' do |
65 | 115 | expect(result.to_a).to contain_exactly( |
66 | 116 | a_hash_including('author' => 'Walter Isaacson', 'name' => 'Steve Jobs'), |
|
73 | 123 | it 'aliases as #to_ary' do |
74 | 124 | expect(result.method(:to_ary).original_name).to eq :to_a |
75 | 125 | end |
| 126 | + |
| 127 | + it 'warns about deprecation' do |
| 128 | + result.to_a |
| 129 | + |
| 130 | + expect(logger).to have_received(:warn).with(a_string_including('Flattening multi search')) |
| 131 | + end |
76 | 132 | end |
77 | 133 |
|
78 | 134 | describe '#to_h' do |
|
0 commit comments