Skip to content

Commit 0edd821

Browse files
committed
[Gem] Refactors helpers integration spec_helper
1 parent 7bd0ff6 commit 0edd821

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

elasticsearch/spec/integration/helpers/bulk_helper_spec.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
18-
raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
19-
17+
require_relative 'helpers_spec_helper'
2018
require 'elasticsearch/helpers/bulk_helper'
21-
require 'spec_helper'
2219
require 'tempfile'
2320

2421
context 'Elasticsearch client helpers' do
2522
context 'Bulk helper' do
26-
let(:client) do
27-
Elasticsearch::Client.new(
28-
host: ELASTICSEARCH_URL,
29-
user: 'elastic',
30-
password: 'changeme'
31-
)
32-
end
3323
let(:index) { 'bulk_animals' }
3424
let(:params) { { refresh: 'wait_for' } }
3525
let(:bulk_helper) { Elasticsearch::Helpers::BulkHelper.new(client, index, params) }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
21+
raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
22+
23+
def client
24+
@client ||= Elasticsearch::Client.new(
25+
host: ELASTICSEARCH_URL,
26+
user: 'elastic',
27+
password: 'changeme'
28+
)
29+
end

elasticsearch/spec/integration/helpers/scroll_helper_spec.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,10 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}"
18-
raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
19-
20-
require 'spec_helper'
17+
require_relative 'helpers_spec_helper'
2118
require 'elasticsearch/helpers/scroll_helper'
2219

2320
context 'Elasticsearch client helpers' do
24-
let(:client) do
25-
Elasticsearch::Client.new(
26-
host: ELASTICSEARCH_URL,
27-
user: 'elastic',
28-
password: 'changeme'
29-
)
30-
end
3121
let(:index) { 'books' }
3222
let(:body) { { size: 12, query: { match_all: {} } } }
3323
let(:scroll_helper) { Elasticsearch::Helpers::ScrollHelper.new(client, index, body) }

0 commit comments

Comments
 (0)