Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to custom search with matching_strategy param #364

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/meilisearch/index/search/matching_strategy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment :) Why is it here and what is it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found something on Stackoverflow: https://stackoverflow.com/questions/37799296/ruby-what-does-the-comment-frozen-string-literal-true-do

My tutor during my first internship also told me it was more performant. Maybe @brunoocasali will be able to say if it's true or not haha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeaah, that's correct with this magic comment. You will save memory because you don't need to allocate more space to store the same string.

In Ruby 3.0. Matz (Ruby’s creator) decided to make all String literals frozen by default.


RSpec.describe 'MeiliSearch::Index - Search with matching_strategy' do
include_context 'search books with nested fields'

it 'does a custom search with a matching strategy ALL' do
response = index.search('another french book', matching_strategy: 'all')

expect(response['hits'].count).to eq(1)
end

it 'does a custom search with a matching strategy LAST' do
response = index.search('french book', matching_strategy: 'last')

expect(response['hits'].count).to eq(2)
end
end