-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsimple_search_spec.rb
More file actions
73 lines (63 loc) · 1.84 KB
/
simple_search_spec.rb
File metadata and controls
73 lines (63 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# encoding: utf-8
require 'spec_helper'
describe Prismic::API do
before do
@api = Prismic.api('https://micro.prismic.io/api', nil)
end
describe '#query' do
it 'returns the documents filter by the query' do
docs = @api.query(Prismic::Predicates::at('document.id', 'UrDejAEAAFwMyrW9'))
docs.size.should == 1
docs[0].id.should == 'UrDejAEAAFwMyrW9'
end
it 'handles multiple predicates' do
docs = @api.query([
Prismic::Predicates::at('document.type', 'all'),
Prismic::Predicates::at('my.all.uid', 'all')
])
docs.size.should == 1
docs[0].id.should == 'WHx-gSYAAMkyXYX_'
end
end
describe '#all' do
it 'returns all documents' do
docs = @api.all()
docs.size.should >= 20
end
end
describe '#get_by_id' do
it 'returns the right document' do
doc = @api.get_by_id('UrDejAEAAFwMyrW9')
doc.id.should == 'UrDejAEAAFwMyrW9'
end
end
describe '#get_by_uid' do
it 'returns the right document' do
doc = @api.get_by_uid('with-uid', 'demo')
doc.id.should == 'V_OoLCYAAFv84agw'
end
end
describe '#get_by_ids' do
it 'returns the right documents' do
docs = @api.get_by_ids(['UrDejAEAAFwMyrW9', 'V2OokCUAAHSZcOUP'])
docs.size.should == 2
docs[0].id.should == 'UrDejAEAAFwMyrW9'
docs[1].id.should == 'V2OokCUAAHSZcOUP'
end
end
describe '#get_by_uids' do
it 'returns the right documents' do
docs = @api.get_by_uids('all', ['all1', 'all2'])
docs.size.should == 2
docs[0].id.should == 'WHyJqyYAAHgyXbcj'
docs[1].id.should == 'WH2PaioAALYBEgug'
end
end
describe '#get_single' do
it 'returns the singleton document of a type' do
# 'single' is the type name
doc = @api.get_single('single')
doc.id.should == 'V_OplCUAACQAE0lA'
end
end
end