Skip to content

Commit 259abfe

Browse files
committed
Move json spec
1 parent ce3a82e commit 259abfe

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

spec/meilisearch/index/documents_spec.rb

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@
3434
expect(index.documents['results'].first.keys).to eq(doc.keys.map(&:to_s))
3535
end
3636

37-
it 'adds JSON documents' do
38-
documents = <<~JSON
39-
[
40-
{ "objectRef": 123, "title": "Pride and Prejudice", "comment": "A great book" },
41-
{ "objectRef": 456, "title": "Le Petit Prince", "comment": "A french book" },
42-
{ "objectRef": 1, "title": "Alice In Wonderland", "comment": "A weird book" },
43-
{ "objectRef": 1344, "title": "The Hobbit", "comment": "An awesome book" },
44-
{ "objectRef": 4, "title": "Harry Potter and the Half-Blood Prince", "comment": "The best book" }
45-
]
46-
JSON
47-
index.add_documents_json(documents, 'objectRef').await
48-
49-
expect(index.documents['results'].count).to eq(5)
50-
end
51-
5237
it 'infers order of fields' do
5338
index.add_documents(documents).await
5439
task = index.document(1)
@@ -132,6 +117,8 @@
132117
NDJSON
133118
end
134119

120+
let(:json_docs) { "[#{ndjson_docs.rstrip.gsub("\n", ',')}]" }
121+
135122
let(:csv_docs) do
136123
<<~CSV
137124
"objectRef:number","title:string","comment:string"
@@ -170,6 +157,11 @@
170157
}
171158
end
172159

160+
it '#add_documents_json' do
161+
index.add_documents_json(json_docs, 'objectRef').await
162+
expect(index.documents['results'].count).to eq(5)
163+
end
164+
173165
it '#add_documents_ndjson' do
174166
index.add_documents_ndjson(ndjson_docs, 'objectRef').await
175167

0 commit comments

Comments
 (0)