Skip to content

Commit fb2029f

Browse files
committed
fix(stemming): handle empty dictionary retrieval gracefully
- add fallback response for empty dictionary retrieval in `StemmingDictionaries` - refactor test setup to ensure proper test isolation - fix webmock configuration in tests
1 parent 52694c4 commit fb2029f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/typesense/stemming_dictionaries.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def upsert(dict_id, words_and_roots_combinations)
3232
end
3333

3434
def retrieve
35-
@api_call.get(endpoint_path)
35+
response = @api_call.get(endpoint_path)
36+
response || { 'dictionaries' => [] }
3637
end
3738

3839
def [](dict_id)

spec/typesense/stemming_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
]
2020
end
2121

22-
before { WebMock.disable! }
23-
after { WebMock.enable! }
22+
before do
23+
WebMock.disable!
24+
# Create the dictionary at the start of each test
25+
client.stemming.dictionaries.upsert(dictionary_id, dictionary)
26+
end
27+
28+
after do
29+
WebMock.enable!
30+
end
2431

2532
it 'can upsert a dictionary' do
2633
response = client.stemming.dictionaries.upsert(dictionary_id, dictionary)

0 commit comments

Comments
 (0)