Skip to content

Commit a8eb0d9

Browse files
committed
Update top-level specs
1 parent 0e55eac commit a8eb0d9

37 files changed

+351
-50
lines changed

elasticsearch-api/spec/elasticsearch/api/actions/bulk_spec.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
url,
2525
params,
2626
body,
27-
headers
27+
headers,
28+
{:endpoint=>"bulk"}
2829
]
2930
end
3031

@@ -59,6 +60,17 @@
5960
context 'when an index is specified' do
6061
let(:url) { 'myindex/_bulk' }
6162

63+
let(:expected_args) do
64+
[
65+
'POST',
66+
url,
67+
params,
68+
body,
69+
headers,
70+
{ defined_params: { index: 'myindex' }, :endpoint=>"bulk"}
71+
]
72+
end
73+
6274
it 'performs the request' do
6375
expect(client_double.bulk(index: 'myindex', body: [])).to be_a Elasticsearch::API::Response
6476
end
@@ -113,6 +125,17 @@
113125
'foo%5Ebar/_bulk'
114126
end
115127

128+
let(:expected_args) do
129+
[
130+
'POST',
131+
url,
132+
params,
133+
body,
134+
headers,
135+
{ defined_params: { index: 'foo^bar' }, :endpoint=>"bulk"}
136+
]
137+
end
138+
116139
it 'performs the request' do
117140
expect(client_double.bulk(index: 'foo^bar', body: [])).to be_a Elasticsearch::API::Response
118141
end

elasticsearch-api/spec/elasticsearch/api/actions/clear_scroll_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
'_search/scroll/abc123',
2626
{},
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { scroll_id: 'abc123' }, endpoint: 'clear_scroll' }
2930
]
3031
end
3132

@@ -41,7 +42,8 @@
4142
'_search/scroll/abc123,def456',
4243
{},
4344
nil,
44-
{}
45+
{},
46+
{ defined_params: { scroll_id: ['abc123', 'def456'] }, endpoint: 'clear_scroll' }
4547
]
4648
end
4749

elasticsearch-api/spec/elasticsearch/api/actions/close_point_in_time_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
'_pit',
2525
{},
2626
nil,
27-
{}
27+
{},
28+
{ endpoint: 'close_point_in_time' }
2829
]
2930
end
3031

elasticsearch-api/spec/elasticsearch/api/actions/count_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
'_count',
2525
{},
2626
nil,
27-
{}
27+
{},
28+
{ endpoint: 'count' }
2829
]
2930
end
3031

@@ -39,7 +40,8 @@
3940
'foo,bar/_count',
4041
{},
4142
nil,
42-
{}
43+
{},
44+
{ defined_params: { index: ['foo', 'bar'] }, endpoint: 'count' }
4345
]
4446
end
4547

@@ -55,7 +57,8 @@
5557
'_count',
5658
{},
5759
{ match: { foo: 'bar' } },
58-
{}
60+
{},
61+
{ endpoint: 'count' }
5962
]
6063
end
6164

elasticsearch-api/spec/elasticsearch/api/actions/create_document_spec.rb

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
[
2424
'PUT',
2525
'foo/_doc/123',
26-
{ op_type: 'create' },
26+
{ endpoint: 'create', op_type: 'create' },
2727
{ foo: 'bar' },
28-
{}
28+
{},
29+
{ defined_params: { id: '123', index: 'foo' }, endpoint: 'create' }
2930
]
3031
end
3132

@@ -39,12 +40,23 @@
3940
[
4041
'PUT',
4142
'foo/_doc/123',
42-
{ op_type: 'create' },
43+
{ endpoint: 'create', op_type: 'create' },
4344
{},
4445
{}
4546
]
4647
end
4748

49+
let(:expected_args) do
50+
[
51+
'PUT',
52+
'foo/_doc/123',
53+
{ endpoint: 'create', op_type: 'create' },
54+
{},
55+
{},
56+
{ defined_params: { id: '123', index: 'foo' }, endpoint: 'create' }
57+
]
58+
end
59+
4860
it 'performs the request' do
4961
expect(client_double.create(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response
5062
end
@@ -56,12 +68,23 @@
5668
[
5769
'PUT',
5870
'foo/_doc/1',
59-
{ op_type: 'create' },
71+
{ endpoint: 'create', op_type: 'create' },
6072
{ foo: 'bar' },
6173
{}
6274
]
6375
end
6476

77+
let(:expected_args) do
78+
[
79+
'PUT',
80+
'foo/_doc/1',
81+
{ endpoint: 'create', op_type: 'create' },
82+
{ foo: 'bar' },
83+
{},
84+
{ defined_params: { id: 1, index: 'foo' }, endpoint: 'create' }
85+
]
86+
end
87+
6588
it 'updates the arguments with the `op_type`' do
6689
expect(client_double.create(index: 'foo', id: 1, body: { foo: 'bar' })).to be_a Elasticsearch::API::Response
6790
end
@@ -79,6 +102,17 @@
79102
]
80103
end
81104

105+
let(:expected_args) do
106+
[
107+
'POST',
108+
'foo/_doc',
109+
{ endpoint: 'create' },
110+
{ foo: 'bar' },
111+
{},
112+
{ defined_params: { index: 'foo' }, endpoint: 'create' }
113+
]
114+
end
115+
82116
it 'updates the arguments with the `op_type`' do
83117
expect(client_double.create(index: 'foo', body: { foo: 'bar' })).to be_a Elasticsearch::API::Response
84118
end

elasticsearch-api/spec/elasticsearch/api/actions/delete_by_query_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
'foo/_delete_by_query',
2626
{},
2727
{ term: {} },
28-
{}
28+
{},
29+
{ defined_params: { index: 'foo' }, endpoint: 'delete_by_query' }
2930
]
3031
end
3132

@@ -46,7 +47,8 @@
4647
'foo/_delete_by_query',
4748
{ q: 'foo:bar' },
4849
{ query: 'query' },
49-
{}
50+
{},
51+
{ defined_params: { index: 'foo' }, endpoint: 'delete_by_query' }
5052
]
5153
end
5254

elasticsearch-api/spec/elasticsearch/api/actions/delete_document_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
'foo/_doc/1',
2626
params,
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'delete' }
2930
]
3031
end
3132

@@ -70,7 +71,8 @@
7071
'foo%5Ebar/_doc/1',
7172
params,
7273
nil,
73-
{}
74+
{},
75+
{ defined_params: { id: 1, index: 'foo^bar' }, endpoint: 'delete' }
7476
]
7577
end
7678

elasticsearch-api/spec/elasticsearch/api/actions/delete_script_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
'_scripts/foo',
2727
{},
2828
nil,
29-
{}
29+
{},
30+
{ defined_params: { id: 'foo' }, endpoint: 'delete_script' }
3031
]
3132
end
3233

elasticsearch-api/spec/elasticsearch/api/actions/exists_document_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
url,
2626
params,
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'exists' }
2930
]
3031
end
3132

elasticsearch-api/spec/elasticsearch/api/actions/explain_document_spec.rb

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
url,
2525
params,
2626
body,
27-
{}
27+
{},
28+
{ defined_params: { id: 1, index: 'foo' }, endpoint: 'explain' }
2829
]
2930
end
3031

@@ -68,6 +69,17 @@
6869
{ q: 'abc123' }
6970
end
7071

72+
let(:expected_args) do
73+
[
74+
method,
75+
url,
76+
params,
77+
body,
78+
{},
79+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'explain' }
80+
]
81+
end
82+
7183
let(:body) do
7284
nil
7385
end
@@ -82,6 +94,17 @@
8294
{ query: { match: {} } }
8395
end
8496

97+
let(:expected_args) do
98+
[
99+
method,
100+
url,
101+
params,
102+
body,
103+
{},
104+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'explain' }
105+
]
106+
end
107+
85108
it 'passes the query definition' do
86109
expect(client_double.explain(index: 'foo', id: '1', body: { query: { match: {} } })).to be_a Elasticsearch::API::Response
87110
end
@@ -92,6 +115,17 @@
92115
'foo%5Ebar/_explain/1'
93116
end
94117

118+
let(:expected_args) do
119+
[
120+
method,
121+
url,
122+
params,
123+
body,
124+
{},
125+
{ defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'explain' }
126+
]
127+
end
128+
95129
it 'URL-escapes the parts' do
96130
expect(client_double.explain(index: 'foo^bar', id: '1', body: { })).to be_a Elasticsearch::API::Response
97131
end

elasticsearch-api/spec/elasticsearch/api/actions/field_caps_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
'foo/_field_caps',
2626
{ fields: 'bar' },
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { index: 'foo' }, endpoint: 'field_caps' }
2930
]
3031
end
3132

elasticsearch-api/spec/elasticsearch/api/actions/get_document_source_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
url,
2626
params,
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'get_source' }
2930
]
3031
end
3132

@@ -69,6 +70,17 @@
6970
'foo%5Ebar/_source/1'
7071
end
7172

73+
let(:expected_args) do
74+
[
75+
'GET',
76+
url,
77+
params,
78+
nil,
79+
{},
80+
{ defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'get_source' }
81+
]
82+
end
83+
7284
it 'URL-escapes the parts' do
7385
expect(client_double.get_source(index: 'foo^bar', id: '1')).to be_a Elasticsearch::API::Response
7486
end

elasticsearch-api/spec/elasticsearch/api/actions/get_document_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
url,
2626
params,
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { id: '1', index: 'foo' }, endpoint: 'get' }
2930
]
3031
end
3132

@@ -68,6 +69,17 @@
6869
'foo%5Ebar/_doc/1'
6970
end
7071

72+
let(:expected_args) do
73+
[
74+
'GET',
75+
url,
76+
params,
77+
nil,
78+
{},
79+
{ defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'get' }
80+
]
81+
end
82+
7183
it 'URL-escapes the parts' do
7284
expect(client_double.get(index: 'foo^bar', id: '1')).to be_a Elasticsearch::API::Response
7385
end

elasticsearch-api/spec/elasticsearch/api/actions/get_script_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
url,
2626
params,
2727
nil,
28-
{}
28+
{},
29+
{ defined_params: { id: 'foo' }, endpoint: 'get_script' }
2930
]
3031
end
3132

0 commit comments

Comments
 (0)