Skip to content

Commit 6f261a1

Browse files
committed
[API] Updates utils spec for escaping spaces and other minor updates
1 parent 46e99ec commit 6f261a1

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

elasticsearch-api/spec/elasticsearch/api/utils_spec.rb

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,14 @@
3030
end
3131

3232
it 'encodes special characters' do
33-
expect(utils.__escape('foo bar')).to eq('foo+bar')
33+
expect(utils.__escape('foo bar')).to eq('foo%20bar')
3434
expect(utils.__escape('foo/bar')).to eq('foo%2Fbar')
3535
expect(utils.__escape('foo^bar')).to eq('foo%5Ebar')
3636
end
3737

3838
it 'does not encode asterisks' do
3939
expect(utils.__escape('*')).to eq('*')
4040
end
41-
42-
it 'users CGI.escape by default' do
43-
expect(CGI).to receive(:escape).and_call_original
44-
expect(utils.__escape('foo bar')).to eq('foo+bar')
45-
end
46-
47-
it 'uses the escape_utils gem when available', unless: defined?(JRUBY_VERSION) do
48-
require 'escape_utils'
49-
expect(CGI).not_to receive(:escape)
50-
expect(EscapeUtils).to receive(:escape_url).and_call_original
51-
expect(utils.__escape('foo bar')).to eq('foo+bar')
52-
end
5341
end
5442

5543
describe '#__listify' do
@@ -77,7 +65,7 @@
7765
context 'when the escape option is set to false' do
7866

7967
it 'does not escape the characters' do
80-
expect(utils.__listify(['foo', 'bar^bam'], :escape => false)).to eq('foo,bar^bam')
68+
expect(utils.__listify(['foo', 'bar^bam'], escape: false)).to eq('foo,bar^bam')
8169
end
8270
end
8371
end
@@ -107,19 +95,19 @@
10795

10896
let(:result) do
10997
utils.__bulkify [
110-
{ :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } },
111-
{ :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } },
112-
{ :delete => { :_index => 'myindexC', :_type => 'mytypeC', :_id => '3' } }
98+
{ index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } },
99+
{ update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } },
100+
{ delete: { _index: 'myindexC', _id: '3' } }
113101
]
114102
end
115103

116104
let(:expected_string) do
117105
<<-PAYLOAD.gsub(/^\s+/, '')
118-
{"index":{"_index":"myindexA","_type":"mytype","_id":"1"}}
106+
{"index":{"_index":"myindexA","_id":"1"}}
119107
{"title":"Test"}
120-
{"update":{"_index":"myindexB","_type":"mytype","_id":"2"}}
108+
{"update":{"_index":"myindexB","_id":"2"}}
121109
{"doc":{"title":"Update"}}
122-
{"delete":{"_index":"myindexC","_type":"mytypeC","_id":"3"}}
110+
{"delete":{"_index":"myindexC","_id":"3"}}
123111
PAYLOAD
124112
end
125113

@@ -379,7 +367,7 @@
379367
end
380368

381369
let(:unsupported_params) do
382-
[ { :foo => { :explanation => 'NOT_SUPPORTED'} }, :moo ]
370+
[ { foo: { explanation: 'NOT_SUPPORTED'} }, :moo ]
383371
end
384372

385373

0 commit comments

Comments
 (0)