search-kit 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +88 -0
- data/coverage/assets/0.10.0/application.css +799 -0
- data/coverage/assets/0.10.0/application.js +1707 -0
- data/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.0/loading.gif +0 -0
- data/coverage/assets/0.10.0/magnify.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +446 -0
- data/demo/videos +112 -0
- data/demo/videos.json +14292 -0
- data/lib/search_kit/configuration.rb +8 -3
- data/lib/search_kit/logger.rb +1 -2
- data/lib/search_kit/version.rb +1 -1
- data/log/service-layer-development.log +282 -0
- data/log/service-layer-test.log +2874 -0
- data/pkg/search-kit-0.0.3.gem +0 -0
- data/search-kit.gemspec +5 -11
- data/spec/integrations/subscriber_model_spec.rb +91 -0
- data/spec/search_kit/cli/documents_spec.rb +234 -0
- data/spec/search_kit/cli/events_spec.rb +243 -0
- data/spec/search_kit/cli/indices_spec.rb +273 -0
- data/spec/search_kit/cli/search_spec.rb +77 -0
- data/spec/search_kit/cli/subscribers_spec.rb +108 -0
- data/spec/search_kit/clients/documents_spec.rb +210 -0
- data/spec/search_kit/clients/events_spec.rb +202 -0
- data/spec/search_kit/clients/indices_spec.rb +193 -0
- data/spec/search_kit/clients/keys_spec.rb +216 -0
- data/spec/search_kit/clients/populate_spec.rb +195 -0
- data/spec/search_kit/clients/scaffold_spec.rb +70 -0
- data/spec/search_kit/clients/search_spec.rb +87 -0
- data/spec/search_kit/clients/subscribers_spec.rb +166 -0
- data/spec/search_kit/configuration_spec.rb +25 -0
- data/spec/search_kit/messages_spec.rb +45 -0
- data/spec/search_kit/models/document_spec.rb +34 -0
- data/spec/search_kit/models/documents_spec.rb +12 -0
- data/spec/search_kit/models/event_spec.rb +14 -0
- data/spec/search_kit/models/events_spec.rb +12 -0
- data/spec/search_kit/models/key_spec.rb +26 -0
- data/spec/search_kit/models/keys_spec.rb +39 -0
- data/spec/search_kit/models/subscriber_spec.rb +22 -0
- data/spec/search_kit/polling/process_spec.rb +65 -0
- data/spec/search_kit/polling_spec.rb +24 -0
- data/spec/search_kit_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- data/tmp/modeling.rb +22 -0
- data/tmp/vidya.json +1 -0
- metadata +101 -19
- data/.gitignore +0 -16
- data/.rspec +0 -2
- data/.rubocop.yml +0 -39
- data/.ruby-version +0 -1
- data/.travis.yml +0 -4
@@ -0,0 +1,273 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SearchKit::CLI::Indices do
|
4
|
+
let(:cli) { described_class.new }
|
5
|
+
let(:json) { response.to_json }
|
6
|
+
let(:response) { {} }
|
7
|
+
let(:slug) { "an-index-slug" }
|
8
|
+
|
9
|
+
subject { cli }
|
10
|
+
|
11
|
+
describe '#archive' do
|
12
|
+
before { allow(cli.client).to receive(:archive).and_return(response) }
|
13
|
+
|
14
|
+
subject { cli.archive(slug) }
|
15
|
+
|
16
|
+
it "calls client.complete with the index slug" do
|
17
|
+
expect(cli.client).to receive(:archive).with(slug)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
|
21
|
+
it "reports on its results" do
|
22
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
23
|
+
subject
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'error handling' do
|
27
|
+
before { allow(cli.client).to receive(:archive).and_raise(*error) }
|
28
|
+
|
29
|
+
context 'unauthorized error' do
|
30
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
31
|
+
|
32
|
+
it do
|
33
|
+
expect(cli.messages).to receive(:unauthorized)
|
34
|
+
subject
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'not found error' do
|
39
|
+
let(:error) { SearchKit::Errors::IndexNotFound }
|
40
|
+
|
41
|
+
it do
|
42
|
+
expect(cli.messages).to receive(:not_found)
|
43
|
+
subject
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'no service error' do
|
48
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
49
|
+
|
50
|
+
it do
|
51
|
+
expect(cli.messages).to receive(:no_service)
|
52
|
+
subject
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#create' do
|
59
|
+
let(:name) { "Index Name" }
|
60
|
+
|
61
|
+
before { allow(cli.client).to receive(:create).and_return(response) }
|
62
|
+
|
63
|
+
subject { cli.create(name) }
|
64
|
+
|
65
|
+
it "calls client.create with the index name" do
|
66
|
+
expect(cli.client).to receive(:create).with(name)
|
67
|
+
subject
|
68
|
+
end
|
69
|
+
|
70
|
+
it "reports on its results" do
|
71
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'error handling' do
|
76
|
+
before { allow(cli.client).to receive(:create).and_raise(*error) }
|
77
|
+
|
78
|
+
context 'unauthorized error' do
|
79
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
80
|
+
|
81
|
+
it do
|
82
|
+
expect(cli.messages).to receive(:unauthorized)
|
83
|
+
subject
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'unprocessable error' do
|
88
|
+
let(:error) { SearchKit::Errors::Unprocessable }
|
89
|
+
|
90
|
+
it do
|
91
|
+
expect(cli.messages).to receive(:unprocessable)
|
92
|
+
subject
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'no service error' do
|
97
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
98
|
+
|
99
|
+
it do
|
100
|
+
expect(cli.messages).to receive(:no_service)
|
101
|
+
subject
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#scaffold' do
|
108
|
+
let(:documents) { [{ title: "Yep", id: 1 }] }
|
109
|
+
let(:documents_json) { documents.to_json }
|
110
|
+
let(:name) { "Index Name" }
|
111
|
+
|
112
|
+
before { allow(cli.client).to receive(:scaffold).and_return(response) }
|
113
|
+
|
114
|
+
subject { cli.scaffold(name, documents_json) }
|
115
|
+
|
116
|
+
it "calls client.create with the index name" do
|
117
|
+
expect(cli.client).to receive(:scaffold).with(name, documents)
|
118
|
+
subject
|
119
|
+
end
|
120
|
+
|
121
|
+
it "reports on its results" do
|
122
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
123
|
+
subject
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'error handling' do
|
127
|
+
before { allow(cli.client).to receive(:scaffold).and_raise(*error) }
|
128
|
+
|
129
|
+
context 'unauthorized error' do
|
130
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
131
|
+
|
132
|
+
it do
|
133
|
+
expect(cli.messages).to receive(:unauthorized)
|
134
|
+
subject
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'unprocessable error' do
|
139
|
+
let(:error) { SearchKit::Errors::Unprocessable }
|
140
|
+
|
141
|
+
it do
|
142
|
+
expect(cli.messages).to receive(:unprocessable)
|
143
|
+
subject
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'json error' do
|
148
|
+
let(:error) { JSON::ParserError }
|
149
|
+
|
150
|
+
it do
|
151
|
+
expect(cli.messages).to receive(:json_parse_error)
|
152
|
+
subject
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'no service error' do
|
157
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
158
|
+
|
159
|
+
it do
|
160
|
+
expect(cli.messages).to receive(:no_service)
|
161
|
+
subject
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe '#show' do
|
168
|
+
before { allow(cli.client).to receive(:show).and_return(response) }
|
169
|
+
|
170
|
+
subject { cli.show(slug) }
|
171
|
+
|
172
|
+
it "calls client.show with the index slug" do
|
173
|
+
expect(cli.client).to receive(:show).with(slug)
|
174
|
+
subject
|
175
|
+
end
|
176
|
+
|
177
|
+
it "reports on its results" do
|
178
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
179
|
+
subject
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'error handling' do
|
183
|
+
before { allow(cli.client).to receive(:show).and_raise(*error) }
|
184
|
+
|
185
|
+
context 'unauthorized error' do
|
186
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
187
|
+
|
188
|
+
it do
|
189
|
+
expect(cli.messages).to receive(:unauthorized)
|
190
|
+
subject
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'not found error' do
|
195
|
+
let(:error) { SearchKit::Errors::IndexNotFound }
|
196
|
+
|
197
|
+
it do
|
198
|
+
expect(cli.messages).to receive(:not_found)
|
199
|
+
subject
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'no service error' do
|
204
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
205
|
+
|
206
|
+
it do
|
207
|
+
expect(cli.messages).to receive(:no_service)
|
208
|
+
subject
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe '#update' do
|
215
|
+
let(:update) { { name: "New Name" } }
|
216
|
+
let(:update_json) { update.to_json }
|
217
|
+
|
218
|
+
before { allow(cli.client).to receive(:update).and_return(response) }
|
219
|
+
|
220
|
+
subject { cli.update(slug, update_json) }
|
221
|
+
|
222
|
+
it "calls client.update with the index slug and given json" do
|
223
|
+
expect(cli.client).to receive(:update).with(slug, update)
|
224
|
+
subject
|
225
|
+
end
|
226
|
+
|
227
|
+
it "reports on its results" do
|
228
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
229
|
+
subject
|
230
|
+
end
|
231
|
+
|
232
|
+
context 'error handling' do
|
233
|
+
before { allow(cli.client).to receive(:update).and_raise(*error) }
|
234
|
+
|
235
|
+
context 'unauthorized error' do
|
236
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
237
|
+
|
238
|
+
it do
|
239
|
+
expect(cli.messages).to receive(:unauthorized)
|
240
|
+
subject
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'unprocessable error' do
|
245
|
+
let(:error) { SearchKit::Errors::Unprocessable }
|
246
|
+
|
247
|
+
it do
|
248
|
+
expect(cli.messages).to receive(:unprocessable)
|
249
|
+
subject
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'json error' do
|
254
|
+
let(:error) { JSON::ParserError }
|
255
|
+
|
256
|
+
it do
|
257
|
+
expect(cli.messages).to receive(:json_parse_error)
|
258
|
+
subject
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
context 'no service error' do
|
263
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
264
|
+
|
265
|
+
it do
|
266
|
+
expect(cli.messages).to receive(:no_service)
|
267
|
+
subject
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SearchKit::CLI::Search do
|
4
|
+
let(:cli) { described_class.new }
|
5
|
+
let(:json) { response.to_json }
|
6
|
+
let(:phrase) { "Michael Jackson" }
|
7
|
+
let(:response) { SearchKit::Models::Search.new }
|
8
|
+
let(:slug) { "an-index-slug" }
|
9
|
+
|
10
|
+
subject { cli }
|
11
|
+
|
12
|
+
describe '#create' do
|
13
|
+
before { allow(cli.client).to receive(:search).and_return(response) }
|
14
|
+
|
15
|
+
subject { cli.create(slug, phrase) }
|
16
|
+
|
17
|
+
it "calls client.search with the slug, and phrase" do
|
18
|
+
expect(cli.client).to receive(:search).with(slug, phrase: phrase)
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
|
22
|
+
it "reports on its results" do
|
23
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String)).twice
|
24
|
+
subject
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'error handling' do
|
28
|
+
before { allow(cli.client).to receive(:search).and_raise(*error) }
|
29
|
+
|
30
|
+
context 'unauthorized error' do
|
31
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect(cli.messages).to receive(:unauthorized)
|
35
|
+
subject
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'unprocessable error' do
|
40
|
+
let(:error) { SearchKit::Errors::Unprocessable }
|
41
|
+
|
42
|
+
it do
|
43
|
+
expect(cli.messages).to receive(:unprocessable)
|
44
|
+
subject
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'bad request error' do
|
49
|
+
let(:error) { SearchKit::Errors::BadRequest }
|
50
|
+
|
51
|
+
it do
|
52
|
+
expect(cli.messages).to receive(:bad_request)
|
53
|
+
subject
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'not found error' do
|
58
|
+
let(:error) { SearchKit::Errors::IndexNotFound }
|
59
|
+
|
60
|
+
it do
|
61
|
+
expect(cli.messages).to receive(:not_found)
|
62
|
+
subject
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'no service error' do
|
67
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
68
|
+
|
69
|
+
it do
|
70
|
+
expect(cli.messages).to receive(:no_service)
|
71
|
+
subject
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SearchKit::CLI::Subscribers do
|
4
|
+
let(:cli) { described_class.new }
|
5
|
+
let(:subscriber) { SearchKit::Models::Subscriber.new }
|
6
|
+
|
7
|
+
subject { cli }
|
8
|
+
|
9
|
+
describe '#create' do
|
10
|
+
let(:email) { "email@example.com" }
|
11
|
+
let(:password) { "password" }
|
12
|
+
|
13
|
+
before { allow(cli.client).to receive(:create).and_return(subscriber) }
|
14
|
+
|
15
|
+
subject { cli.create(email, password) }
|
16
|
+
|
17
|
+
it "calls create on the client with the given parameters" do
|
18
|
+
expect(cli.client)
|
19
|
+
.to receive(:create)
|
20
|
+
.with(email: email, password: password)
|
21
|
+
|
22
|
+
subject
|
23
|
+
end
|
24
|
+
|
25
|
+
it "sends a message that the subscriber has been created" do
|
26
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
27
|
+
subject
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'error handling' do
|
31
|
+
before { allow(cli.client).to receive(:create).and_raise(*error) }
|
32
|
+
|
33
|
+
context 'bad request error' do
|
34
|
+
let(:error) { SearchKit::Errors::BadRequest }
|
35
|
+
|
36
|
+
it do
|
37
|
+
expect(cli.messages).to receive(:bad_request)
|
38
|
+
subject
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'unprocessable error' do
|
43
|
+
let(:error) { SearchKit::Errors::Unprocessable }
|
44
|
+
|
45
|
+
it do
|
46
|
+
expect(cli.messages).to receive(:unprocessable)
|
47
|
+
subject
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'not found error' do
|
52
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
53
|
+
|
54
|
+
it do
|
55
|
+
expect(cli.messages).to receive(:no_service)
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#info' do
|
63
|
+
before { allow(cli.client).to receive(:info).and_return(subscriber) }
|
64
|
+
|
65
|
+
subject { cli.info }
|
66
|
+
|
67
|
+
it "calls info on the client" do
|
68
|
+
expect(cli.client).to receive(:info)
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
|
72
|
+
it "sends a message that the subscriber has been created" do
|
73
|
+
expect(cli.messages).to receive(:info).with(an_instance_of(String))
|
74
|
+
subject
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'error handling' do
|
78
|
+
before { allow(cli.client).to receive(:info).and_raise(*error) }
|
79
|
+
|
80
|
+
context 'unprocessable error' do
|
81
|
+
let(:error) { SearchKit::Errors::Unauthorized }
|
82
|
+
|
83
|
+
it do
|
84
|
+
expect(cli.messages).to receive(:unauthorized)
|
85
|
+
subject
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'not found error' do
|
90
|
+
let(:error) { SearchKit::Errors::SubscriberNotFound }
|
91
|
+
|
92
|
+
it do
|
93
|
+
expect(cli.messages).to receive(:not_found)
|
94
|
+
subject
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'no service error' do
|
99
|
+
let(:error) { [Faraday::ConnectionFailed, "Message"] }
|
100
|
+
|
101
|
+
it do
|
102
|
+
expect(cli.messages).to receive(:no_service)
|
103
|
+
subject
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|